933 points
8 4 2


Hello, experts.

I am a new Python learner. I’ve been learning computer programming since last week. I am learning new things every single day. Today, I have got a problem when working with a python dictionary. I’ve created a Python dictionary. For example:

a = {'Name':'Steve', 'Age':30, 'Designation':'Programmer'}

is my dictionary. Now, my question is, how I am gonna find how many elements are available in my dictionary while I need to use the dictionary in my program? My question might be sounds silly to you, but it needs to be answered badly. I am looking forward to hearing from you, mate. Thanks for your kind help


In Python. dictionaries are the collection of mixed values. As far as your given dictionary is concerned, it is holding the key-value pairs of data in it. In your question, you are asking to get the length of a dictionary. Python has many built-in functions. One of the most popular and widely used functions is .len() function. To get the length you can use the len() function. This way:

a = {'Name':'Steve', 'Age':30, 'Designation':'Programmer'}

More Posts

How to convert list into dictionary in Python Prasandeep Gautam - Oct 17, 2020
Make a copy of a dictionary in python amna - Apr 13
convert list of tuples to dictionary python IamAdinath - Jan 28
How to create a dictionary from a list in Python? Hafsa_Rao - Aug 19
How to remove something from a dictionary python? Hafsa_Rao - Aug 11
invert a dictionary in python SharadMagar450 - Aug 8
How to check if a key exists in dictionary Python? Hafsa_Rao - Aug 7
How to check if something is in a dictionary python amna - Jul 25
C# get length of list Hafsa_Rao - Oct 4
How to get the length of an array in JavaScript? Hafsa_Rao - Sep 4