Definition
The difference_update() method removes the items that exist in both sets.
The difference_update() method is different from the difference() method, because the difference() method returns a new set, without the unwanted items; the difference_update() method removes the unwanted items from the original set.
Syntax
set.difference_update(set)
Parameters
Parameter | Description |
---|---|
set | Required. The set to check for differences in |
Examples:
persons1 = {"Mark", "Jeff", "Ivan", "Mike"}
persons2 = {"Arnel", "Marie", "Ivan", "Alex"}
persons1.difference_update(persons2)
print(persons1)