Write a Python program to multiply all the items in a dictionary.
Example 1:
Input: {"a": 5, "b": 3, "c": 2}
Output: 30
Example 2:
Input: {"x": 7, "y": 2, "z": 1}
Output: 14
You can use Python’s built-in reduce() function.
from functools import reduce
def multiply_dict(d):
return reduce((lambda x, y: x * y), 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.