Python 3 reference · Set Methods
Python Set symmetric_difference_update() Method
Update the set in place to keep elements in either set but not both. The same as a ^= b.
Python 3 Since 3.0
Syntax
set.symmetric_difference_update(other)
Parameters
| Parameter | Description |
|---|---|
other |
An iterable. |
Return value
None.
Examples
s = {1, 2, 3}
s.symmetric_difference_update({3, 4})
print(s)
Output
{1, 2, 4}flags = {"bold"}
flags ^= {"bold"} # toggle off
flags ^= {"italic"} # toggle on
print(flags)
Output
{'italic'}Version history
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
set.symmetric_difference()· Return a new set with elements in either set but not both. The same as a ^ b.- Python Sets · tutorial