Basic example of finding the length of a dictionary

Python3




dict1 ={'Name':'Steve', 'Age':30, 'Designation':'Programmer'}
 
print("Dictionary:", dict1)
print("Length of dictionary:", len(dict1))


Output:

Dictionary: {'Name': 'Steve', 'Age': 30, 'Designation': 'Programmer'}
Length of dictionary: 3

Get length of dictionary in Python

To calculate the length of a dictionary, we can use the Python built-in len() method. The len()  method returns the number of keys in a Python dictionary.

Similar Reads

Python Dict len() Syntax

Syntax: len(Dict) Return: It returns an integer which is the length of the string....

Basic example of finding the length of a dictionary

Python3 dict1 ={'Name':'Steve', 'Age':30, 'Designation':'Programmer'}   print("Dictionary:", dict1) print("Length of dictionary:", len(dict1))...

Finding length of nested dictionary

...