Python Practice › Set Programs › Program 16
Sum of a set
Write a Python program to add up the elements of a set.
Input
{10, 20, 30}Output
60
Approach
sum().
Solution
print(sum({10, 20, 30}))Output
60
Learn the concept
New to this topic? Read the lesson, then come back.