Conditional evaluation of several lists in Python



How can several lists be evaluated in Python?

For instance this works for one list:

dataEnteringNode = IN[0]

for i in IN[0]:
if i == “aaa”: c.append(“is aaa”)
elif i == “bbb”: c.append(“is bbb”)
elif i == “ccc”: c.append(“is ccc”)
else: c.append(“is none”)
OUT = c

But if I want to enter several lists in the Python code and compare elements from several lists, something like:

dataEnteringNode0 = IN[0]
dataEnteringNode1 = IN[1]
dataEnteringNode2 = IN[2]

for i in IN[0] and j in IN[1]:

_ if i == “aaa” and j ==“aaa”: c.append(“is aaa”)_
_ elif i == “bbb” and j !=“ccc”: c.append(“is bbb”)_
_ elif i == “ccc”: c.append(“is ccc”)_
_ else: c.append(“is none”)_

OUT = c

Please, can anybody clarify?



This could help:


Not exactly what I’m asking but thanks, it’s good to know.


just look at the zip function. You can zip also more than 2 lists, but they need to have the same lengh

looks like that

a =in[0]
b =in[1]

for h,g in zip(a,b)
do something()

or one “for loop” in another

for a in lista:
___for b in listb

1 Like

You beat me to it :slight_smile:
Anyway here’s an exaple:


Wow, that’s great! Thanks both :slight_smile: