I am trying to know if any item of sublists contain a specific item list, so the results is a True or False for each sublist. for example:
IN[0]=[1,2,3],[4,5,6],[7,8,9]
IN[1]=[1]
OUT=[True,False,False]
In designscript I use the nodes String.Contains and AllFalse to filter but I am trying to do the same with python but I got this so far, it works with simple list but not sublists:
import clr
def ListMatch(ls1, ls2):
len1 = len(ls1)
len2 = len(ls2)
if len1 != len2:
return False
for i in range(len1):
if ls1[i] != ls2[i]:
return False
return True
# Inputs
masterList = IN[0]
searchList = IN[1]
answer = False
for i in range(len(masterList)):
if ListMatch(masterList[i], searchList):
answer = True
break
OUT = answer
for example same list of numbers in[0] and a single item on in[1] for example=[1], if the item in[1] is contained in any of the sublists, give me true, if not, give me false, so in this example the output would be 3 items (true,false,false) because 3 sublists on in[0]
That is a bit of a mess, however I’m lost as to what data you have which is causing the issue. If you post the previously requested screenshot of the data structure I can try to help simplify, but short of that you’ll have to run with what you’ve got.