python dictionary get number of keys code example
Example 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
Example 2: how many keys in a dictionary python
> a = {'foo':42, 'bar':69}
> len(a)
2