# If condition fails

**URL:** <https://forum.dynamobim.com/t/if-condition-fails/76997>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [May 27, 2022, 12:03pm UTC](https://forum.dynamobim.com/t/if-condition-fails/76997 "2022-05-27T12:03:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shashank.baganeACM](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@shashank.baganeACM](https://forum.dynamobim.com/u/shashank.baganeACM)\
**Post date:** [May 27, 2022, 12:03pm UTC](https://forum.dynamobim.com/t/if-condition-fails/76997/1 "2022-05-27T12:03:13Z")

</div>

Hi all I am trying to use if condition in python and get the result. But it is failing to give the required result.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/d/6d6f89b7701067f731ec307aab62fca85a9277aa.png)

my IN[0] is elements and IN[1] true or false

the code is as below:

```auto
import clr

import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')

import System
from System.Collections.Generic import *

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

def tolist(obj1):
	if hasattr(obj1," __iter__"): return obj1
	else: return [obj1]

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

#Do some action in a Transaction

TransactionManager.Instance.EnsureInTransaction(doc)
if IN[1] == "False":
	OUT = element

else:
	OUT = []

TransactionManager.Instance.TransactionTaskDone()

```

It should give me out put as elements what I fed the list of elements based on the condition. But it is always giving me the empty list only.

Please let me know where I am missing

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 27, 2022, 12:13pm UTC](https://forum.dynamobim.com/t/if-condition-fails/76997/2 "2022-05-27T12:13:12Z")

</div>

@shashank.baganeACM ,

```auto
OUT = []

for i in element:
    if i == "False":
	OUT.append(i)

else:
	OUT.append("no element")

```

try this in your code

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 27, 2022, 1:31pm UTC](https://forum.dynamobim.com/t/if-condition-fails/76997/3 "2022-05-27T13:31:29Z")

</div>

Are you feeding a boolean or a string? Either way, they don’t match. I’m guessing you have a boolean, which would just be `False` in Python. Right now you’re checking for a string.

---

<div class="post-metadata">

**Author:** ![shashank.baganeACM](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@shashank.baganeACM](https://forum.dynamobim.com/u/shashank.baganeACM)\
**Post date:** [May 27, 2022, 3:18pm UTC](https://forum.dynamobim.com/t/if-condition-fails/76997/4 "2022-05-27T15:18:27Z")

</div>

Thanks @Nick_Boyts It worked for me. I was feeding the boolen and I have changed it to False.

Thanks @Draxl_Andreas for your response.
