Write a Python program to sum all the items in a dictionary.
Example 1:
Input: {"a": 5, "b": 3, "c": 8}
Output: 16
Example 2:
Input: {"x": 7, "y": 6, "z": 9}
Output: 22
You can use Python’s built-in sum() function and dict.values() method.
def sum_dict(d):
return sum(d.values())
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.