Hi,
I want to check if a list contains 2 specific items, and I want the result to return “True” only if it contains both items:
Thanks in advance for any help,
Zirjay
Hi,
I want to check if a list contains 2 specific items, and I want the result to return “True” only if it contains both items:
Thanks in advance for any help,
Zirjay
Thanks Jonathan, it worked fine for the upper part of my list, but at the bottom items it’s returning “true” even if it only contains 1 of the criteria:
Thanks,
Zirjay
@zilong245 try using the String.Contains node form the archilab package
@zilong245 Actually I don’t think String.Contains will work.
You could try this python code:
OUT=[]
for lst in IN[0]:
if all (item in lst for item in IN[1]):
OUT.append(True)
else:
OUT.append(False)
Perfect! Thanks salvatoredragotta!
If I may take it a step further…
What if I only want the test to return “true” when it contains both items and not include another item:
Thanks so much,
Zirjay
@zilong245 you’ll have to give more information about what you are trying to achieve for me to answer your question
For index 6, although it contains “100” and “001”, I want to it to return “false” because it also contains “010”:
I tried modifying the script, but I am a total noob to this.
Thanks again,
Zirjay
@zilong245 What about this?
OUT=[]
for lst in IN[0]:
if all (item in IN[1] for item in lst):
OUT.append(True)
else:
OUT.append(False)
List contains with cross product and then a second node for ‘all true’ or a list.contains searching for ‘false’ should work here. Lacing and levels will be key.
@salvatoredragotta This didn’t work but I got it to work somehow with this:
Thanks for your help
2 posts were split to a new topic: Return 'true’ only if it satisfies 2 conditions