Different Update Methods
Sets in Python
James Uejio
05:56
James Uejio RP Team on April 29, 2020
@Sciencificity Thank you for the comment and this is definitely tricky. So what actually happened is Python evaluated the right hand side of the expression first (b ^ c) and then modified a.
You can think of it like this:
a = {1,2,3}
b = {3,4,5}
c = {1,3,5,6}
# step 1
print(b ^ c)
{1, 4, 6}
# step 2
print(a ^ {1, 4, 6})
{2, 3, 4, 6}
# step 3
Modify a to be equal to {2, 3, 4, 6}
Become a Member to join the conversation.

Sciencificity on April 27, 2020
Hi James,
Here again I believe that the
symmetric_difference_update()only works on 2 sets for a reason (hence the ^= operator too, should be used only with 2 sets)If we take the 3 set example used in the videos, and introduce a 3 in the last set we notice the weird behaviour for more than 2 sets.
Well, that’s my thinking anyway. Please let me know if I am thinking about it incorrectly?
Thanks for a really great course! It is just this concept which is confusing for me.