I have a code block that creates a list of 60 numbers. I am trying to remove numbers in the list if they are less than 2.1. To do this I have written this code:
result = []
for item in area:
if item < 2.1:
result.append(item)
area = result
The code block appears red and says there is an error. Is this a problem with my syntax or am I missing an easier way to do this?
in Python you can do this:
#Assign your output to the OUT variable.
OUT = [i for i in IN[0] if i < 2.1]
1 Like
Thank you, How do I go about assigning OUT to the output? Sorry I am new to dynamo
It needs to be in a python script not a code block as shown by Konrad.
Thank you so much for your help, it worked!
Can this code be easily changed to instead of removing the number to changing it to something else? Just asking for future reference
Thank you for that, I’m sure I’ll use it again
4 Likes
Ah! Indeed. It even looks like a more elegant solution if you ask me. I went off the assumption that user posted a sample of Python code, but your solution looks better to me.