Home >>Python Set Methods >Python Set difference_update() Method
Python set difference_update() method is used to remove the items that exist in both the sets. It is different from the difference() method because the difference() method returns a new set without the unwanted items where as the difference_update() method removes the unwanted items from the original set.
Syntax:set.difference_update(set)
Parameter | Description |
---|---|
set | This is a required parameter. It defines the set to check for differences in. |
x = {"Abhi", "Jerry", "Mickey"}
y = {"Wings", "Alpha", "Jerry"}
x.difference_update(y)
print(x)