Python Sum of Dictionary Values
Given a dictionary, calculate the sum of all its numeric values.
Example
def returnSum(myDict):
sum = 0
for i in myDict:
sum = sum + myDict[i]
return sum
dict = {'a': 100, 'b':200, 'c':300}
print("Sum :", returnSum(dict))
Executing the above code outputs the result:
Sum : 600Other Extensions
Python3 Examples