+ 1
Python Set Symmetric Difference
A = {1, 2, 3, 4, 5} B = {1,4, 5, 6, 7, 8} C = {3,1} print(A^B^C) OUTPUT: {1, 2, 6, 7, 8} Why 1 is there? It is common so it should be eliminated.
2 Antworten
+ 5
It's the same as print(A^(B^C)) (or maybe (A^B)^C if it's left associated, I don't know)
Try this and it'll make sense:
D = B^C
print(D)
print(A^D)
+ 3
harshit
For the first
{1, 2, 3, 4, 5} ^ {1,4, 5, 6, 7, 8}
== {2, 3, 6, 7, 8} (without 1)
then
{2, 3, 6, 7, 8} ^ {3,1}
= {1, 2, 6, 7, 8}
So 1 in game again