Is there an opposite of the List.Contains node?

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

Will this solve your problem? :slight_smile:

1 Like

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:
image

Thanks,
Zirjay

@zilong245 try using the String.Contains node form the archilab package

image

@zilong245 Actually I don’t think String.Contains will work.

You could try this python code:

image

OUT=[]
for lst in IN[0]:
	if all (item in lst for item in IN[1]):
		OUT.append(True)
	else:
		OUT.append(False)
1 Like

Perfect! Thanks salvatoredragotta!

1 Like

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”:
image

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.

1 Like

@salvatoredragotta This didn’t work but I got it to work somehow with this:
image

Thanks for your help :slight_smile:

1 Like

2 posts were split to a new topic: Return 'true’ only if it satisfies 2 conditions

2 Likes