# list containing any item of another list

**URL:** <https://forum.ansible.com/t/list-containing-any-item-of-another-list/30054>\
**Category:** Ansible Project\
**Created:** [April 3, 2019, 10:49pm UTC](https://forum.ansible.com/t/list-containing-any-item-of-another-list/30054 "2019-04-03T22:49:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_E](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@Adam\_E](https://forum.ansible.com/u/Adam_E)\
**Post date:** [April 3, 2019, 10:49pm UTC](https://forum.ansible.com/t/list-containing-any-item-of-another-list/30054/1 "2019-04-03T22:49:50Z")

</div>

Hi, wondering if there is any cleaner way to see if two lists have 1 or more intersecting values?

the following works for me

> # returns true
> 
> {{ [‘value1’, ‘value2’] | intersect([‘value1’, ‘value2’]) | length \> 0 }}
> 
> # returns false
> 
> {{ [‘value3’, ‘value4’] | intersect([‘value1’, ‘value2’]) | length \> 0 }}

just wondering if there is a cleaner looking solution that I am not aware of as I am using it frequently.  
something like would be handy.

---

<div class="post-metadata">

**Author:** ![Soniya\_panwar](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Soniya\_panwar](https://forum.ansible.com/u/Soniya_panwar)\
**Post date:** [April 5, 2019, 11:04am UTC](https://forum.ansible.com/t/list-containing-any-item-of-another-list/30054/2 "2019-04-05T11:04:14Z")

</div>

Hello Adam E,

You have got the implementation correct. Intersect is the correct method to be used.  
You may refer the playbook mentioned below:
