Python Script - Multiple inputs and referencing the same index value

Hi. I have 2 lists as inputs to a Python Script node in dynamo. The first list is a list of duct connector orientations (“in” or “out”). The second list is a list of the system abbreviation that the connector is a part of (“SA”, “RA”, “EA”, or “OA”)

.

I need a python script that compares the item at Index[1] from input 1 against index[1] from input 2, but I’m having a hard time figuring it out. Here’s what I have. It tells me line 15 (the ‘if’ statement) is wrong - traceback error - but I have no clue how to rewrite it.

Any help would be greatly appreciated!

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

Nodes = IN[0]
System = IN[1]
a=[]

# Place your code below this line
for i in Nodes and System:
	if System[i] == "In" and (System[i] == "SA" or System[i] == "OA"):
		a.append(1)
	else:
		a.append(0)
OUT = a

Well, I almost immediately saw that the first item in my ‘if’ statement needed to say ‘Nodes’ instead of ‘System’, but that didn’t fix it.

You want something like this:

nodes = IN[0]
systems = IN[1]

for node,system in zip(nodes,systems):
    [your function here]

This keeps the items in nodes and systems paired together. It’s cleaner and better suited for paired inputs, but you could also do something like what you were attempting:

nodes = IN[0]
systems = IN[0]

for i in range(len(nodes)):
    node = nodes[i]
    system = systems[i]
    [your function here]
    i = i+1

This manually steps through each item based on the number of items in the list.

Thank you very much. That worked perfectly!