Hi, I have this code, and I have a problem in the output
print("This program finds the intersection of two sets")
sequenceOne = input("Please enter the space-separated elements of the first set: ")
sequenceTwo = input("Please enter the space-separated elements of the second set: ")
sequenceOne = sequenceOne.split()
sequenceTwo = sequenceTwo.split()
listOfIntersection = []
for i in sequenceOne:
for j in sequenceTwo:
if (i==j):
sequenceOne.remove(j)
sequenceTwo.remove(i)
listOfIntersection.append(i)
if not sequenceOne or sequenceTwo:
pass
it should print string or number intersection between the two sequences.
sequence one : 12 k e 34 1.5 12 hi 12 0.2
sequence two: 1.5 hi 12 0.1 54 12 hi hi hi
intersection: {12, 1.5, 12, hi} #only one [hi] since it occurs once in sequence one
but in my code it skips [hi], and i don't know why
and only printing:
Hi, I have this code, and I have a problem in the output
it should print string or number intersection between the two sequences.
but in my code it skips [hi], and i don't know why
and only printing: