- We have seen the applications of union, intersection, difference, and symmetric difference operations, but these operations do not make any changes or mutations to the set.
- We can use the following operations to create mutations to a set: .update() or |=
- Update the set by adding elements from an iterable/another set.
>>> H = set("Hacker")
>>> R = set("Rank")
>>> H.update(R)
>>> print H
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
- .intersection_update() or &= Update the set by keeping only the elements found in it and an iterable/another set.