Question
Find common elements in two lists
Solution
β Verified
Using set intersection we can get the common element b/w two list. This is the fast way to get unique common elements, but order is not preserved
list1 = [1, 2, 3, 4]
list2 = [3, 4, 5, 6]
common = list(set(list1) & set(list2))
print(common) # Output: [3, 4]
Click here to download practice questions on
Python Lists