Find the Intersection of Two List Using Python
Find the Intersection of Two List Using Python
Program Source Code
aList = []
bList = []
len1 = int(input("Enter Length of List 1:"))
for i in range(len1):
e1 = int(input("Enter
Element:"))
aList.append(e1)
print("List A:",aList)
len2 = int(input("Enter Length of List 2:"))
for i in range(len2):
e2 = int(input("Enter
Element:"))
bList.append(e2)
print("List B:",bList)
#intersection operation
inSet = set.intersection(set(aList),set(bList))
inList = list(inSet)
print("------------------")
print("List A:",aList)
print("List B:",bList)
print("A & B:",inList)
Output
Related Video
Post a Comment