This set method is used to remove uncommon items, meaning if we apply this method to set A and B, then the output will be the items which are common to both the sets. Also, this method has no return type so all the changes are done in original set itself. This method takes sets as an argument.
For two set intersection
For two or more intersection
This method takes an argument
- Set A is being taken
- Set B is being taken
- intersection_update() method is being applied in set A with the help of set B
- Value of set A is being printed
- Set with common item present in both sets is printed as output
- What is difference between intersection and intersection update method?
intersection() method gives the output of common items in which are present inside compared sets, this output is printed into another variable. Whereas in intersection_update() method the output is common items which are present inside compared sets, but the output is printed in the original set itself, that is original set is get updated and no other variable is involved here.