Answers for "Python - Count the Number of Keys in a Python Dictionary"

1

get number of key in dictionary python

#Call len(obj) with a dictionary as obj to count the number 
#of key-value pairs in the dictionary.

a_dictionary = {"a": 1, "b": 2}
print(len(a_dictionary))

OUTPUT:
2
Posted by: Guest on October-22-2020
0

Python - Count the Number of Keys in a Python Dictionary

pythonCopydict1 = {'a':1,'b':2,'c':3}
print(len(dict1.keys()))
Posted by: Guest on May-30-2021
1

count dictionary keys

len(dict)
Posted by: Guest on March-03-2020

Code answers related to "Python - Count the Number of Keys in a Python Dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language