easy +10 pts

Running Product of Integers

Compute the product of all integers from the start of the list up to each position.

Write a function `running_product(nums)` that takes a list of integers `nums` and returns a new list where the element at index `i` is the product of all integers from index `0` up to index `i` inclusive. For an empty list, return an empty list.

Constraints

The input list may be empty. Each integer is any Python integer (can be negative, zero, or positive). The list length is at most 10^4. The product may be large but within Python's arbitrary precision integer range.

Example

>>> running_product([1, 2, 3, 4])
[1, 2, 6, 24]
>>> running_product([3, -1, 2])
[3, -3, -6]
>>> running_product([])
[]
10 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Keep a running variable that holds the product so far as you iterate.
For each number, multiply the running product by that number and append it to the result.
You don't need to modify the original list; build a new list.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.