Python program to find Sum of Items in a Dictionary

# sum of values in dictionary
#initialisation
dic={ 'x':455, 'y':223, 'z':300, 'p':908 }
print("Dictionary: ", dic)
#using sum() and values()
print("sum: ",sum(dic.values()))

OUTPUT:

Dictionary:  {'x': 455, 'y': 223, 'z': 300, 'p': 908}
sum:  1886

Sharing Is Caring

Leave a Comment