Check for equality between any items in two lists

Hi All,

I have two lists of strings I want to get a true output if any of the items from the second list appear in the first list. I have come across this problem before and used the Python code below. However I am wondering if it is possible with nodes?

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.
"Activities"
strs = IN[0]
fields = IN[1]

out0 = []
out1 = []
out2 = []
out3 = []
out4 = []
out5 = []

for i in range(len(strs)):
if strs[i] == "Activities":
out0.append(fields[i])
elif strs[i] == "Personnel":
out0.append(fields[i])
elif strs[i] == "Notes":
out0.append(fields[i])
elif strs[i] == "Room Finishes":
out1.append(fields[i])
elif strs[i] == "Room DC Notes":
out1.append(fields[i])
elif strs[i] == "Item No.":
out2.append(fields[i])
elif strs[i] == "Transfer":
out2.append(fields[i])
elif strs[i] == "New":
out2.append(fields[i])
elif strs[i] == "Total No. Item":
out2.append(fields[i])
elif strs[i] == "Item Description":
out2.append(fields[i])
elif strs[i] == "Alt. Code":
out2.append(fields[i])
elif strs[i] == "Group":
out2.append(fields[i])
elif strs[i] == "Electrical":
out3.append(fields[i])
elif strs[i] == "Electrical Requirements":
out3.append(fields[i])
elif strs[i] == "RED Electrical Notes":
out3.append(fields[i])
elif strs[i] == "Mechanical":
out4.append(fields[i])
elif strs[i] == "Mechanical Requirements":
out4.append(fields[i])
elif strs[i] == "RED Mechanical Notes":
out4.append(fields[i])
elif strs[i] == "Noise":
out5.append(fields[i])
elif strs[i] == "Noise Requirements":
out5.append(fields[i])
elif strs[i] == "RED Noise Notes":
out5.append(fields[i])

# Assign your output to the OUT variable.
OUT = out0, out1, out2, out3, out4, out5

Is this what you’re trying to do?

If you have multiple matches, you can use a List.AllIndicesOf node if there are multiple matches:

1 Like