Python Practice › Dictionary Programs › Program 23
Product of dictionary values
Write a Python program to multiply all the values of a dictionary.
Input
{"a": 2, "b": 4, "c": 5}Output
40
Approach
math.prod(d.values()).
Solution
import mathprint(math.prod({"a": 2, "b": 4, "c": 5}.values()))Output
40
Learn the concept
New to this topic? Read the lesson, then come back.