Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (2.6k points)
have a list of sets:

setlist = [s1,s2,s3...]

I want s1 ∩ s2 ∩ s3 ...

I can write a function to do it by performing a series of pairwise s1.intersection(s2), etc.

Is there a recommended, better, or built-in way?

1 Answer

0 votes
by (7.2k points)

It is the best way to find the intersection of multiple sets in Python.

u = set.intersection(k1, k2, k3)

If the sets are in a list, this translates to:

u = set.intersection(*setlist)

Browse Categories

...