In this python dictionary program, we will get the total length of a dictionary.
Steps to solve the program
- Take a dictionary as input.
- Use the len() function to calculate the length of the dictionary.
- The len() function will return the key-value pairs in the dictionary.
- To get the total number of items in the dictionary multiply the len() function by 2.
- Print the output.
D1 = {'virat':50,'Rohit':40,'Rahul':25}
print(len(D1)*2)
Output :
6