Python Practice › Set Programs › Program 4
Length of a set
Write a Python program to find the number of items in a set.
Input
{"a", "b", "c", "a"}Output
3
Approach
len()counts unique items.
Solution
print(len({"a", "b", "c", "a"}))Output
3
Learn the concept
New to this topic? Read the lesson, then come back.