w3resource logo
Python Exercises

Python Exercise: Find the length of a set

Python sets: Exercise-15 with Solution

Write a Python program to find the length of a set.

Sample Solution:-

Python Code:

#Create a set
seta = set([5, 10, 3, 15, 2, 20])
#Find the length use len()
print(len(seta))

Sample Output:

6

Python Code Editor:

#Create a set
seta = set([5, 10, 3, 15, 2, 20])
#Find the length use len()
print(len(seta))

Improve this sample solution and post your code through Disqus