Home >>Python Set Methods >Python Set intersection() Method
Python set intersection() method is used to return a set that contains the similarity between two or more sets.
Syntax:set.intersection(set1, set2 ... etc)
Parameter | Description |
---|---|
set1 | This is a required parameter. It defines the set to search for equal items in. |
set2 | This is an optional parameter. It defines the other set to search for equal items in. |
x = {"Abhi", "Jerry", "Mickey"}
y = {"Wings", "Alpha", "Jerry"}
z = x.intersection(y)
print(z)
x = {"a", "b", "c"}
y = {"c", "d", "e"}
z = {"f", "g", "c"}
result = x.intersection(y, z)
print(result)