In this tutorial, we going to learn how to get the length of the dictionary by using len() built function

1. What is len() ?

Len() is a Python built function, that returns the number of items of an object.

2. Syntax

len(your_dictionary)

3. Example: Getting the length of the dictionary

in this followin example, we'll get length of a dictionary


#dictionary
dictionary1 = {'name':'cat', 'age':'22', 'nationality':'MA'}

#Return the number of items dictionary:
print(len(dictionary1))

output

3

4. Summary

In this article, we've learned how to get the length of a dictionary by using Len() built-function, you can also use this Len() with a tuple, list, and string.

English today is not an art to be mastered it's just a tool to use to get a result