# If condition in Python

Hi All,

I want to filter the walls by the thickness and name. So I have written this code in Python, i think the reason why its not working, is the fact that i combine two lists. Can somebody have a look and tell me what I am doing wrong and how it can be solved.

Rasa

the second loop should start from 4 space from the first loop , like this :

for x in range â€¦
____for i in range â€¦
________if etc â€¦

Thank u for replying. I saw that also and fixed it. still it does not work. I think that naam[x].contains(â€śwerkâ€ť);_ is the problem

try changing and name[i].contains(â€śwerkâ€ť): to:
and â€śwerkâ€ť in name[i]:

1 Like

I donâ€™t get an error, but it does not work. ides 8 should be true

I think itâ€™s looping over too many times, try this instead:

``OUT = [True if x>100 and x<200 and "werk" in i else False for x,i in zip(dikte,naam)]``
1 Like

Still nothing.

try:

``````test=[]
for x,i in zip(dikte,naam):
if x>100 and x<200 and "werk" in i:
test.append(True)
else:
test.append(False)`
``````

`OUT = test`

Can you show the preview of the Element.GetParameterValueByName node?

Tnx, this works great. Could you explain why this one worked and what i did wrong?
Still trying to learn Python

Both of them worked, if you didnt managed, then some other error must have been made.

in addition you could do it as a definition

``````def GetWerk(dikte, naam, t=[]):
for x, i in zip(dikte, naam):
if x > 100 and x < 200 and 'werk' in i:
t.append(True)
else:
t.append(False)
return t

OUT = GetWerk(IN[0], IN[1])
``````

Home.dyn (3.9 KB)

5 Likes