+ 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.
17th Apr 2022, 3:49 PM
Paul
Paul - avatar
+ 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)
19th Apr 2022, 3:02 AM
Tibor Santa
Tibor Santa - avatar
+ 4
Bitwise operator ^. XOR = exclusive or. Sets each bit to 1 if only one of two bits is 1
17th Apr 2022, 3:29 PM
Paul
Paul - avatar