The intersection_update() finds the intersection of different sets and updates it to the set that calls the method.
Example
intersection_update() Syntax
The syntax of the intersection_update() method is:
A.intersection_update(*sets)
Here, *sets indicates that set A can be intersected with one or more sets.
intersection_update() Parameter
The intersection_update() method allows an random number of arguments:
*sets- denotes that the methods can take one or more arguments
For example,
A.intersection_updata(B, C)
Here, the method has two arguments, B and C.
intersection_update() Return Value
The intersection_update() method doesn't return any value.
Example: Python Set intersection_update()
Output
A = {4}
B = {2, 3, 4, 5, 6}
C = {4, 5, 6, 9, 10}
In the above example, we have used intersection_update() to compute the intersection between sets A, B and C. The result of intersection is updated to set A.
That's why we have A = {4} as the output because 4 is the only item that is present in all three sets. Whereas, sets B and C are unchanged.