Skip to content

Home

Partial sum list

Creates a list of partial sums.

from itertools import accumulate

def cumsum(lst):
  return list(accumulate(lst))

cumsum(range(0, 15, 3)) # [0, 3, 9, 18, 30]

More like this

Start typing a keyphrase to see matching snippets.