I am trying to find the intersection and union of two lists for an assignment, however, I cannot use sets. From set theory, an intersection between two sets is the elements that are in both sets. A union is all elements in both sets, without repetition. So far I have:
setA = [1,2,3,4,5,6,7,8,9]
setB = [1,5,0,9]
def getUnion(a, b):
return a + b
def getIntersection(a, b):
return
My union function is returning duplicates. Is there a way to simply find the union?
Also, what is the best approach to find the intersection?