Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python list intersection

# intersection of two lists (lst1 & lst2)
In [1]: x = ["a", "b", "c", "d", "e"]

In [2]: y = ["f", "g", "h", "c", "d"]

In [3]: set(x).intersection(y)
Out[3]: {'c', 'd'}
# has_intersection = bool(set(x).intersection(y)) -> True
 
PREVIOUS NEXT
Tagged: #python #list #intersection
ADD COMMENT
Topic
Name
4+7 =