from itertools import accumulate import operator nums = [1, 2, 3, 4] print(list(accumulate(nums, operator.mul)))