Python Set intersection_update() method

Facebooktwitterredditpinterestlinkedinmailby feather

Python Set intersection_update() method

The set.intersection_update() method in Python removes the items that is not present in both sets.

It is different from the set.intersection() method, because the intersection()method returns a new set, with only  the common elements whereas the intersection_update() method removes the unwanted items from the original set.

Syntax

Parameter

set1- This parameter represents the set to search for equal items

set2(optional)- This argument signifies the other set to search for equal items. One can compare as many sets as needed, only need to separate the sets with a comma.

Return

None

Example 1

Output

Example 2

Output

Example 3

Output

Facebooktwitterredditpinterestlinkedinmailby feather