 # Elif dynamo python between number

Hi all I am trying to achieve the following I would like to get numbers 0-3 depending on the input

-45 to -135 = 0
-45 to 45 = 1
-135 to -180 = 3
45 to 135 = 2
135 to 180 = 3

I am not even sure if that is the simplest way to interpret that

# Enable Python support and load DesignScript library
import clr
***from Autodesk.DesignScript.Geometry import ****

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line

numberList = IN

y = []
for x in numberList:
*** if x < 45:***
*** elif 45 <= x < 135:***
*** elif 135 <= x < 180:***
*** elif 0 <= x < -45:***
*** elif -45 <= x < -135:***
*** elif -135 <= x < -180:***

#Assign your output to the OUT variable.
OUT = y

this is the code I have come up with.

[Python Practise.dyn|attachment]
Python Practise Dynamo Forum.dyn (11.1 KB)

Figured it out below if anyone wants the code for something similar

``````indent preformatted text by 4 spaces

# Enable Python support and load DesignScript library
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line

numberList = IN

y = []

for x in numberList:

if  -180 <= x <= -135:

elif -136 <= x <= -45:

elif -45 <= x <= 45:

elif 45 <= x <= 135:

elif 135 <= x <= 180:

#Assign your output to the OUT variable.
OUT = y``````

This is somewhat of a PSA, as you’ll see many people doing this, but a range is actually redundant in nested conditions like this. All you need is:

``````if x <= -135: