Answers for "python overlap of two lists"

8

intersection of two lists python

>>> a = [1,2,3,4,5]
>>> b = [1,3,5,6]
>>> list(set(a) & set(b))
[1, 3, 5]
Posted by: Guest on August-10-2020
1

get overlap between two lists python

# Python program to illustrate the intersection
# of two lists using set() method
def intersection(lst1, lst2):
    return list(set(lst1) & set(lst2))
  
# Driver Code
lst1 = [15, 9, 10, 56, 23, 78, 5, 4, 9]
lst2 = [9, 4, 5, 36, 47, 26, 10, 45, 87]
print(intersection(lst1, lst2))
Posted by: Guest on July-24-2021

Code answers related to "python overlap of two lists"

Python Answers by Framework

Browse Popular Code Answers by Language