Home >>Python Set Methods >Python Set intersection_update() Method
The intersection update() method in python set is used to remove the unwanted elements (which are not available in all sets if the comparison is done between more than two sets) from the original set.
Syntax:set.intersection_update(set1, set2 ... etc)
Parameter | Description |
---|---|
set1 | It is Required. The set to be compared |
set2 | It is Optional. Multiple sets to be compared |
x = {"php", "python", "codeigniter"}
y = {"blue", "python", "orange"}
x.intersection_update(y)
print(x)
a = {"abc", "def", "phptpoint"}
b = {"phptpoint", "jkl", "mno"}
c = {"mno", "pqr", "phptpoint"}
a.intersection_update(b, c)
print(a)