In Python you can use a.intersection(b) to find the items common to both sets.
a.intersection(b)
Is there a way to do the disjoint opposite version of this? Ite
The best way is a list comprehension.
a = [ 1,2,3,4] b = [ 8,7,9,2,1] c = [ element for element in a if element not in b] d = [ element for element in b if element not in a] print(c) # output is [ 3,4] print(d) # output is [8,7,9]
You can join both lists