Python program to take two lists and display common members in both list.

#Python program to take two lists and display common members in both list.

array=[]
arr=[]

N=int(input("Enter number of elements in list1:"))

for i in range(N):
    list1=int(input("Enter element %d:"% (i+1)))
    array.append(list1)


n=int(input("\nEnter number of elements in list2:"))

for i in range(n):
    list2=int(input("Enter element %d:"% (i+1)))
    arr.append(list2)

print("\n")

if(set(array).intersection(arr)):
    print("common members are: ",set(array).intersection(arr))
else:
    print("No common members in list 1 and list 2.")

Comments

Popular posts from this blog

Python program to calculate age and year when user will be 100 years old

Python program to print numbers less than 5 from the list.