Home >>Python Set Methods >Python Set intersection_update() Method

Python Set intersection_update() Method

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 Values

Parameter Description
set1 It is Required. The set to be compared
set2 It is Optional. Multiple sets to be compared
Here is an example of Python Set intersection_update() Method:

x = {"php", "python", "codeigniter"}
y = {"blue", "python", "orange"}
x.intersection_update(y) 
print(x)

Output:
{'python'}
Example 2:

a = {"abc", "def", "phptpoint"}
b = {"phptpoint", "jkl", "mno"}
c = {"mno", "pqr", "phptpoint"}
a.intersection_update(b, c)
print(a)

Output:
{'phptpoint'}

No Sidebar ads