# Is there an opposite of the List.Contains node?

**URL:** <https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884>\
**Category:** Lists-Logic\
**Created:** [May 14, 2018, 11:05am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884 "2018-05-14T11:05:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 14, 2018, 11:05am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/1 "2018-05-14T11:05:15Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/a/ea55ae26d95f2ecc485032a1bbe78d2acd4edb6d.png)

Thanks in advance for any help,  
Zirjay

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [May 14, 2018, 11:19am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/2 "2018-05-14T11:19:31Z")

</div>

Will this solve your problem? 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/0/b0479eb571dabf065af4ee31e65cee63a9e3f10f.png)

---

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 15, 2018, 1:08am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/3 "2018-05-15T01:08:17Z")

</div>

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](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/5/05b8ef039bee608896071ca9b6190db5c18c755a.png)

Thanks,  
Zirjay

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [May 15, 2018, 1:17am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/4 "2018-05-15T01:17:22Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/a/3a8c5bc6d258b8913861fc3cc4ed25ad01e1bc15.png)

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [May 15, 2018, 1:36am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/5 "2018-05-15T01:36:11Z")

</div>

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

You could try this python code:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/4/74b8283b2d3be2f5232ea5ccebd25c44af98572d.png)

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

---

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 15, 2018, 1:59am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/6 "2018-05-15T01:59:28Z")

</div>

Perfect! Thanks salvatoredragotta!

---

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 15, 2018, 2:08am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/7 "2018-05-15T02:08:30Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aa501b6d93343541360d650e224976b51573565b.png)

Thanks so much,  
Zirjay

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [May 15, 2018, 2:18am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/8 "2018-05-15T02:18:37Z")

</div>

@zilong245 you’ll have to give more information about what you are trying to achieve for me to answer your question

---

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 15, 2018, 2:27am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/9 "2018-05-15T02:27:56Z")

</div>

For index 6, although it contains “100” and “001”, I want to it to return “false” because it also contains “010”:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/e/6ea003e3d8d51ed1ca86a3d9ba101dd216b8c6b7.png)

I tried modifying the script, but I am a total noob to this.

Thanks again,  
Zirjay

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [May 15, 2018, 2:32am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/10 "2018-05-15T02:32:59Z")

</div>

@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)
```

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 15, 2018, 2:44am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/11 "2018-05-15T02:44:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zilong245](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@zilong245](https://forum.dynamobim.com/u/zilong245)\
**Post date:** [May 15, 2018, 2:45am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/12 "2018-05-15T02:45:18Z")

</div>

@salvatoredragotta This didn’t work but I got it to work somehow with this:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/2401e19911fd29e454e4a72184a59ec5594b1585.png)

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [May 15, 2018, 4:03am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/13 "2018-05-15T04:03:31Z")

</div>

2 posts were split to a new topic: [Return 'true’ only if it satisfies 2 conditions](https://forum.dynamobim.com/t/return-true-only-if-it-satisfies-2-conditions/21916)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [May 15, 2018, 4:05am UTC](https://forum.dynamobim.com/t/is-there-an-opposite-of-the-list-contains-node/21884/14 "2018-05-15T04:05:53Z")

</div>

> [@zilong245](#):
>
> I want the result to return “True” only if it contains both items:

 ![20180515-1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/7505dd9d51c1e06c08f1a1b19635c379fd61978f.png)
