20 Program to find common items from two lists using Python

Program:

l1 = list()

l1 = [x for x in input("Enter any 5 value for l1: ").split()]



l2 = list()

l2 = [x for x in input("Enter any 5 value for l2: ").split()]



common = list()



for i in l1:

    for j in l2:

        if i == j:

            common.append(i)



common = set(common)

print("Common Items: ",common)


Output:

Program to find common items from two lists using Python



Previous
Next Post »