Python – Length of Dictionary

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

Reference – Python len() builtin function

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

Python Program

dictObject = {'a': 24, 'b': 78, 'c': 33}
length = len(dictObject)
print(f'Length of this dictionary is {length}.')
Try Online


Length of this dictionary is 3.


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