Python Practice › Set Programs › Program 39

Intersection of several sets

EasySet Programs · 39 of 48

Write a Python program to find the items shared by several sets.

Advertisement
Input
{1, 2, 3}, {2, 3, 4}, {3, 4, 5}
Output
{3}

Approach

  1. set.intersection(*sets).

Solution

Python
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.

More set programs

← All 48 Set Programs

Leave a Comment