how to check how many key value pairs are in a dict python 1

how to check how many key value pairs are in a dict python

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

Here is what the above code is Doing:
1. We create a dictionary called a_dictionary.
2. We create a variable called dictionary_length and set it equal to the length of a_dictionary.
3. We print out the value of dictionary_length.

Similar Posts