len()
` function to get the length of a dictionary, which will return the number of key-value pairs in the dictionary. Here is an example program :# Create a dictionary
my_dict = {'apple': 2, 'banana': 3, 'orange': 4}
# Get the length of the dictionary
dict_length = len(my_dict)
# Print the length of the dictionary
print("The length of the dictionary is:", dict_length)
The length of the dictionary is: 3
len()
` function to get the length of the dictionary, and store the result in a variable called `dict_length
`. Finally, we print the length of the dictionary using the `print()
` function.