Write a Python program to find common items from two lists


This program finds the common elements in two lists num1 and num2. It first converts both lists into sets using the set() function. Then, it uses the '&' operator which is the intersection operator that returns the common elements in the two sets. The result is then printed which is a set containing the common elements in the two lists num1 and num2. In this case the common element is 67.

Source Code

num1 = [23,45,67,78,89,34]
num2 = [34,89,55,56,39,67]
print(set(num1) & set(num2))
 

Output

{89, 34, 67}

Example Programs