# Beginner at Python

**URL:** <https://forum.dynamobim.com/t/beginner-at-python/72863>\
**Category:** Developers\
**Tags:** python, dynamo\
**Created:** [February 1, 2022, 9:30pm UTC](https://forum.dynamobim.com/t/beginner-at-python/72863 "2022-02-01T21:30:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Sanford](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@J\_Sanford](https://forum.dynamobim.com/u/J_Sanford)\
**Post date:** [February 1, 2022, 9:30pm UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/1 "2022-02-01T21:30:31Z")

</div>

I could simplify and control the graph I am working on a lot better if I knew a little python. I need to write a boolean, and I can write exactly what I need in Revit syntax. Here is how it would look if it were a Revit Family Formula:

IF(OR(FloorPlan, CeilingPlan, Areaplan, 1\<2, IF(OR(Elevation, Section, 2\<1, 2\<1))

So basically, if input is Floorplan, Celingplan, or Areaplan, True; if input is Elevation or Section, False, if none, False.

What I really need in python is the same, except for my first boolean result I need a specific list of indices (0, 1, 9) and for my second boolean result a different list of indices (9, 19). For the third boolean result, I dont know, probably null. I know this is super basic but Im a super noob to python. Plz send help 😃

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [February 2, 2022, 12:11am UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/2 "2022-02-02T00:11:46Z")

</div>

Assuming your input is a string (text), then the below statement would work. You have some redundancy in your statement as you’re yielding false under the condition that nothing or an elevation/section is provided, so you could just check for the things that yield true, and return false otherwise.

Python is a bit different to how Revit manages if statements, but this should work for an input into a Python node as a string. I’ve added some redundancy to make the control flow logic a bit clearer. You wouldn’t have to technically pass the input/result variables if you went completely efficiently (you could just reference IN[0] each time, and OUT for the true/false outcome.

```auto
input = IN[0]

if input == "FloorPlan" or input == "Ceilingplan" or input == "Areaplan":
	result = True
else:
	result = False

OUT = result

```

I’d suggest trying out my series here on Python, and don’t rush:

[![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/0/508f42b3a5b718754ae453b8be5c2bc86b814881.jpeg "Python 101 #1: Data Types") ](https://www.youtube.com/watch?v=-k81u9NNEPQ)

This part deals with If statements specifically:

[![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/c/ec6074c3704c35a53f72bd58abc32615b610f33b.jpeg "Python 101 #6: If Statements") ](https://www.youtube.com/watch?v=f8u8gYdE-As)

---

<div class="post-metadata">

**Author:** ![andy.leong](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andy.leong/32/97352_2.png) [@andy.leong](https://forum.dynamobim.com/u/andy.leong)\
**Post date:** [February 2, 2022, 12:32am UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/3 "2022-02-02T00:32:59Z")

</div>

In addition to previous reply, you’d use an elif: statement as well so you could test for items that arent views to return a null result.

You would also have to wrap it all up in a for statement assuming you are passing in a list of items.

```auto
input = IN[0]
results = []

for i in input:
	if i == "FloorPlan" or i == "Ceilingplan" or i == "Areaplan":
		result = True
	elif i == "Section" or i == "Elevation":
		result = False
	else:
		result = ""
	results.append(result)

OUT = results

```

![python](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/2/525316ff347c723f723cabd9f55f05ab807c8f61.png)

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [February 2, 2022, 12:52am UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/4 "2022-02-02T00:52:36Z")

</div>

Even shorter 🐍 😉

```auto
items = {"Item1","Item2","Item3"}
input = IN[0]
OUT = input in items

```

---

<div class="post-metadata">

**Author:** ![J\_Sanford](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@J\_Sanford](https://forum.dynamobim.com/u/J_Sanford)\
**Post date:** [February 2, 2022, 4:08am UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/5 "2022-02-02T04:08:15Z")

</div>

Thanks Gavin, Ive really been meaning to get through your python for Dynamo series 😃 Maybe this is the kick in the ass I needed to finally buckle down on it. Feel like Ive been stuck in hello world for an eternity

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [February 2, 2022, 4:22am UTC](https://forum.dynamobim.com/t/beginner-at-python/72863/6 "2022-02-02T04:22:46Z")

</div>

No worries - I’m still moreorless sitting at hello world for C# so I know the feeling. Any queries feel free to drop a comment on the videos 😉
