Python Set intersection() method

Python Set intersection() method

The set.intersection() method in Python returns a new set with elements that are similar between two or more sets.

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

This method returns a new set with elements that are common to all sets.

Example 1

Output

Example 2

Output