Web Analytics

Python set.intersection() Method

Set Method Intersection

The intersection() method returns a set that contains the similarity between two or more sets.

Meaning: The returned set contains only items that exist in both sets, or in all sets if the comparison is done with more than two sets.

Syntax

set.intersection(set1, set2...)

Parameters

Parameter Description
set1 Required. The set to search for equal items in
set2... Optional. The other sets to search for equal items in, separated by commas

Return Value

A new set containing the intersection of sets.

Example

Using the intersection() method:

Output
Click Run to execute your code

Related Functions