Intersection of lists (PYTHON)
n1 = int(input("Enter the size of list 1 : "))
l1 = [int(input("enter the elements : ")) for i in range(n1)]
n2 = int(input("Enter the size of list 2 : "))
l2 = [int(input("enter the elements : ")) for i in range(n2)]
l3 = []
for i in range(n1):
if l1[i] not in l3 and l1[i] in l2:
l3.append(l1[i])
for i in range(n2):
if l2[i] not in l3 and l2[i] in l1:
l3.append(l2[i])
print(l3)
Comments
Post a Comment