Python Practice › Set Programs › Program 39
Intersection of several sets
Write a Python program to find the items shared by several sets.
Input
{1, 2, 3}, {2, 3, 4}, {3, 4, 5}Output
{3}Approach
set.intersection(*sets).
Solution
sets = [{1, 2, 3}, {2, 3, 4}, {3, 4, 5}]print(set.intersection(*sets))Output
{3}Learn the concept
New to this topic? Read the lesson, then come back.