Articles

Program to find size of a dictionary in Python

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.

 

size of a dictionary in python

 


Basic Python Programs

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 & Data Science Enthusiast
Page Views :    Published Date : Oct 13,2022  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!