- intersection_update() is a python function which are used to find the intersection of two set and it update the answer in set1.
Syntax-
set1.intersection_update(set2)
Example
set1 is {1,2,3,4}
set2 is {3,4,5,6,7}
intersection_update() update the set1 and put the intersection of both sets inside set1.
program-
set1={1,2,3,4,5,6}
set2={9,8,7,6,5,4,3}
print("Set1 is",set1)
print("Set2 is",set2)
print(set1.intersection_update(set2))
print(set1)
print(set2)
Set1 is {1, 2, 3, 4, 5, 6}
Set2 is {3, 4, 5, 6, 7, 8, 9}
None
{3, 4, 5, 6}
{3, 4, 5, 6, 7, 8, 9}