Open this example in the interactive library
Source code
from itertools import accumulate
print(list(accumulate([2, 3, 5])))Sample output
[2, 5, 10]

Accumulate running totals. A self-contained example using the Python standard library.
Open this example in the interactive library
from itertools import accumulate
print(list(accumulate([2, 3, 5])))[2, 5, 10]