Set Methods
symmetric_difference_update()
Update the set in place with the symmetric difference of itself and another.
set.symmetric_difference_update(other)
set.symmetric_difference_update() updates the calling set in place, keeping only elements found in either set but not in both.
Arguments
Parameters
| Name | Description |
|---|---|
| other | An iterable to compute symmetric difference against. |
Result
Returns
None, modifies the set in place.
Run it
Try it
Run it and change it
data = {"a", "b", "c"}
data.symmetric_difference_update({"b", "c", "d"})
print(sorted(data)) Output
Press Run to see what it prints.Worth knowing
- In-place operator: The
^=operator performs in-place symmetric difference update.