# How to filter two list both ture value on list?

**URL:** <https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [April 5, 2024, 3:06am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742 "2024-04-05T03:06:49Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 3:06am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/1 "2024-04-05T03:06:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jmark](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jmark](https://forum.dynamobim.com/u/jmark)\
**Post date:** [April 5, 2024, 3:16am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/2 "2024-04-05T03:16:30Z")

</div>

you need to put a condition on the mask, search the forum for this particular node, you’ll see tons of example

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [April 5, 2024, 5:35am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/3 "2024-04-05T05:35:18Z")

</div>

Try using an _And_ node from Math \> Logic  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c4bab653eeb8f7d24190dd5997d0907993e6f67e.png)

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 7:37am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/4 "2024-04-05T07:37:06Z")

</div>

Got Error.

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

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 8:05am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/5 "2024-04-05T08:05:31Z")

</div>

you means search the list.filterbyboolmask?

---

<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:** [April 5, 2024, 8:16am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/6 "2024-04-05T08:16:03Z")

</div>

Feels like that should have worked…

Try this instead - replace the And node with a List.Create node, Wire that into a List.Transpose node so you get ‘pairs’, and then use a List.AllTrue node to return a single boolean for each pair.

The resulting list of booleans becomes the mask for the FilterByBoolMask node.

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [April 5, 2024, 9:34am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/7 "2024-04-05T09:34:37Z")

</div>

Should be simple enough with Python.

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

```auto
#Define Function
def Boolean_Evaluation(list1, list2):
        list1 and list2 are True, otherwise False.
        
	#Error if lists do not match
    if len(list1) != len(list2):
        raise ValueError("Input lists must have equal lengths.")

    # Evaluate items at matching indices
    output = [a and b for a, b in zip(list1, list2)]
    return output
    
#Inputs
input_list1 = IN[0]
input_list2 = IN[1]

result = Boolean_Evaluation(input_list1, input_list2)
OUT =(result)

```

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 9:41am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/8 "2024-04-05T09:41:19Z")

</div>

Actually I want filter the vertical pipe, boths Ture value shall be in list. Others pipe out of list (added hanger)…Thanks.

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

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 9:44am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/9 "2024-04-05T09:44:36Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/9/695c053a6a9892468f7bbbe7b17938cb6968d038.png)

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [April 5, 2024, 9:46am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/10 "2024-04-05T09:46:05Z")

</div>

Can you show the python in the node and also the list structure that is going into the list part of the Boolean mask?

---

<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:** [April 5, 2024, 9:50am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/11 "2024-04-05T09:50:50Z")

</div>

Set the input on the List.AllTrue node to use @L2 and you should be all set. Sorry for missing that.

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 9:59am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/12 "2024-04-05T09:59:45Z")

</div>

HI, I am a beginner, how to set use @L2?

---

<div class="post-metadata">

**Author:** ![pe\_simon](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pe\_simon](https://forum.dynamobim.com/u/pe_simon)\
**Post date:** [April 5, 2024, 10:02am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/13 "2024-04-05T10:02:23Z")

</div>

Hi, i am a beginner, how to show python in the node?

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

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [April 5, 2024, 10:03am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/14 "2024-04-05T10:03:54Z")

</div>

Double click on it and then paste in the code that i gave you.

---

<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:** [April 5, 2024, 10:15am UTC](https://forum.dynamobim.com/t/how-to-filter-two-list-both-ture-value-on-list/99742/15 "2024-04-05T10:15:58Z")

</div>

Hit the “\>” symbol on the right side of the input.
