Pronouncement

Yes, that's right. Guido rejected the idea for a built-in prod() function because he thought it was rarely needed.

Python 3.8 Update

In Python 3.8, prod() was added to the math module:

Copy>>> from math import prod
>>> prod(range(1, 11))
3628800

Alternative with reduce()

As you suggested, it is not hard to make your own using reduce() and operator.mul():

Copydef prod(iterable):
    return reduce(operator.mul, iterable, 1)

>>> prod(range(1, 5))
24

In Python 3, the reduce() function was moved to the functools module, so you would need to add:

Copyfrom functools import reduce

Specific case: Factorials

As a side note, the primary motivating use case for prod() is to compute factorials. We already have support for that in the math module:

Copy>>> import math

>>> math.factorial(10)
3628800

Alternative with logarithms

If your data consists of floats, you can compute a product using sum() with exponents and logarithms:

Copy>>> from math import log, exp

>>> data = [1.2, 1.5, 2.5, 0.9, 14.2, 3.8]
>>> exp(sum(map(log, data)))
218.53799999999993

>>> 1.2 * 1.5 * 2.5 * 0.9 * 14.2 * 3.8
218.53799999999998
Answer from Raymond Hettinger on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-itertools-product
Itertools.Product() - Python - GeeksforGeeks
July 12, 2025 - Example 1: In this example, we are using the repeat parameter of the product() function to generate the Cartesian product of the list [0, 1] repeated 3 times.
🌐
Tutorialspoint
tutorialspoint.com › python › python_itertools_product_function.htm
Python itertools.product() Function
Now, we use itertools.product() ... "Salad"] drinks = ["Coke", "Water"] result = itertools.product(mains, sides, drinks) for meal in result: print(meal)...
🌐
Medium
medium.com › analytics-vidhya › itertools-product-in-python-e63de572c796
itertools.product() in Python
February 6, 2024 - For example, product(A, B) returns the same as ((x,y) for x in A for y in B) . Alright, so before I show you an example of how it is used in practice, let us first break-down the heavy words in the above sentence (for all the ones who didn’t ...
🌐
W3Schools
w3schools.com › python › ref_math_prod.asp
Python math.prod() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... # Import math Library import math sequence = (2, 2, 2) #Return the product of the elements print(math.prod(sequence)) Try it Yourself »
🌐
Scaler
scaler.com › home › topics › python program to find product of list
Python Program to Find Product of List - Scaler Topics
May 4, 2023 - Continue through the list to the end, multiplying each integer by the product. Your ultimate answer will be determined by the value that is retained in the finished product. Below is the implementation of the discussed viewpoint. ... To multiply all the numbers in the list in Python, we can use the numpy.prod() function of numpy module.
🌐
Pythontic
pythontic.com › modules › math › prod
The prod function of Python math module | Pythontic.com
The prod() function returns the product of the elements from an iterable. The Python example uses a starting product value of 4, which is multiplied with the first element by the prod() function.
🌐
Educative
educative.io › answers › what-is-the-itertoolsproduct-method-in-python
What is the itertools.product() method in Python?
Line 5: We invoke the product function with lst and repeat=2 as arguments to obtain the cartesian product of lst with itself. Line 7: We define a list of numbers, lst11. Line 8: We define a list of characters, lst2.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Cartesian Product of Lists in Python: itertools.product | note.nkmk.me
August 11, 2023 - l1 = [1, 2, 3] l2 = ['A', 'B'] p = itertools.product(l1, l2) print(p) # <itertools.product object at 0x105e6e2c0> print(type(p)) # <class 'itertools.product'> ... You can obtain the combination of elements from each list as a tuple using a for loop.
🌐
EyeHunts
tutorial.eyehunts.com › home › python product of list | example code
Python product of list | Example code
November 14, 2023 - Here’s a simple example: def product_of_list(lst): result = 1 for num in lst: result *= num return result # Example usage: my_list = [2, 3, 4, 5] result = product_of_list(my_list) print(result) In this example, the product_of_list function ...
🌐
Python Examples
pythonexamples.org › python-math-prod
Python math.prod() - Product of Elements in Iterable
Discover how to use Python's math.prod() function to calculate the product of elements in an iterable. This tutorial covers the syntax, examples with different data types, handling empty iterables, and special cases like infinity and NaN.
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › prod
Python Numpy prod() - Calculate Product | Vultr Docs
November 15, 2024 - Use the prod() function to calculate the total product of the array elements.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-math-prod-method
Python - math.prod() method - GeeksforGeeks
January 23, 2020 - # Python Program to explain math.prod() ... 2, 3, 4, 5] # Calculate the product of # of all elements present # in the given list product = math.prod(arr, start = 2) print(product)...
🌐
W3Schools
w3schools.com › python › pandas › ref_df_product.asp
Pandas DataFrame product() Method
This function does NOT make changes to the original DataFrame object. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
Python
docs.python.org › 3 › library › itertools.html
itertools — Functions creating iterators for efficient looping
Cartesian product of the input iterables. Roughly equivalent to nested for-loops in a generator expression. For example, product(A, B) returns the same as ((x,y) for x in A for y in B).
🌐
Interactive Chaos
interactivechaos.com › en › python › function › mathprod
math.prod | Interactive Chaos
January 28, 2021 - Python scenarios · Full name · math.prod · Library · math · Syntax · math.prod(iterable, start = 1) Description · The math.prod function calculates the product of all elements of the iterable included as the first argument. The start parameter determines the first value to consider in ...
Top answer
1 of 10
245

Historically, Guido vetoed the idea: http://bugs.python.org/issue1093

As noted in that issue, you can make your own:

Copyfrom functools import reduce # Valid in Python 2.6+, required in Python 3
import operator

reduce(operator.mul, (3, 4, 5), 1)
2 of 10
166

In Python 3.8, the prod function was added to the math module. See: math.prod().

Older info: Python 3.7 and prior

The function you're looking for would be called prod() or product() but Python doesn't have that function. So, you need to write your own (which is easy).

Pronouncement on prod()

Yes, that's right. Guido rejected the idea for a built-in prod() function because he thought it was rarely needed.

Alternative with reduce()

As you suggested, it is not hard to make your own using reduce() and operator.mul():

Copyfrom functools import reduce  # Required in Python 3
import operator
def prod(iterable):
    return reduce(operator.mul, iterable, 1)

>>> prod(range(1, 5))
24

Note, in Python 3, the reduce() function was moved to the functools module.

Specific case: Factorials

As a side note, the primary motivating use case for prod() is to compute factorials. We already have support for that in the math module:

Copy>>> import math

>>> math.factorial(10)
3628800

Alternative with logarithms

If your data consists of floats, you can compute a product using sum() with exponents and logarithms:

Copy>>> from math import log, exp

>>> data = [1.2, 1.5, 2.5, 0.9, 14.2, 3.8]
>>> exp(sum(map(log, data)))
218.53799999999993

>>> 1.2 * 1.5 * 2.5 * 0.9 * 14.2 * 3.8
218.53799999999998

Note, the use of log() requires that all the inputs are positive.

🌐
USAVPS
usavps.com › home › blog › python tutorial: how to use product function in python?
Python Tutorial: How to Use product Function in Python? - USAVPS
March 18, 2026 - The product function in Python’s itertools module is a powerful tool for generating Cartesian products of input iterables. By understanding its syntax and parameters, you can leverage this function in various programming scenarios, from testing to data analysis.
🌐
Invent with Python
inventwithpython.com › pythongently › exercise13
Exercise 13 - Sum & Product
The calculateSum() function adds these numbers and returns the sum while the calculateProduct() function multiplies these numbers and returns the product. If the list passed to calculateSum() is empty, the function returns 0. If the list passed to calculateProduct() is empty, the function returns ...
🌐
Stellar Grove
stellargrove.com › how-to-blog › how-to-perform-sum-product-function-in-python
How to Perform Sum Product Function in Python — Stellar Grove
May 19, 2023 - Once you have installed the NumPy library, you can import it into your Python code using the following command: ... Next, you can use the np.sum() function to calculate the sum product. Here's an example:
Address   Annapolis, MD USA