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