Python – Length of Set

To find the length of a set in Python, call len() builtin function and pass the set object as argument. len() function returns the number of items in the set.

Reference – Python len() builtin function

In the following example, we will take a set, and find its length using len() function.

Python Program

setObject = {'a', 'b', 'c'}
length = len(setObject)
print(f'Length of this set is {length}.')
Try Online


Length of this set is 3.


In this Python Tutorial, we learned how to find the length of Python Set object using len() function, with example program.