Program to find size of a dictionary in Python
In the python programming article, we are going to learn
-
program to find the size of the dictionary in python
Program to find the size of a dictionary in Python
The program is as follows:
# Owner : TutorialsInhand Author : Devjeet Roy
db = {
1 : "Devjeet Roy",
2 : "Ajit Agarwal",
3 : "Dhananda Seth",
4 : "Dhanush Singh"
}
print("The size of the dictionary is:",len(db))
The output of the program is as follows:
PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
The size of the dictionary is: 4
Few important tips about the program
1. By finding the size of the dictionary, we mean to say that finding the number of key-value pairs present in the dictionary.
2. The len() function helps us to find the length of the dictionary in Python.
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :
Published Date :
Oct 13,2022