+ 6
Like this it works fot sets (not lists)
A={1,2,3,4,5,6}
B={1,4,5,6,7}
print (A^B)
The result is 2, 3, 7. All numbers in A or B, but not in both.
+ 6
Set operations can be done by using methods or operators, they are equivalent.
When a and b are sets:
a | b == a.union(b)
a & b == a.intersection(b)
a - b == a.difference(b)
a ^ b == a.symmetric_difference(b)
(a <= b) == a.issubset(b)
(a >= b) == a.issuperset(b)
+ 4
Bitwise operator ^. XOR = exclusive or. Sets each bit to 1 if only one of two bits is 1