Product of dictionary values

EasyDictionary Programs · 23 of 94

Write a Python program to multiply all the values of a dictionary.

Advertisement
Input
{"a": 2, "b": 4, "c": 5}
Output
40

Approach

  1. math.prod(d.values()).

Solution

Python
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.

More dictionary programs

← All 94 Dictionary Programs

Leave a Comment