Python ProgrammingPython Programming

How to find common elements between two lists in Python?

Common Items between two Lists

thelist1 = [1, 4, 2, 3, 5, 4]
thelist2 = [3, 4, 5, 9, 10, 11]

list1_as_set = set(thelist1)
intersection = list1_as_set.intersection(thelist2)

intersection_as_list = list(intersection)

print(intersection_as_list)
[3, 4, 5]