Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cumsum(values):
- return [sum(values[:i]) for i in range(1, len(values))]
- def cumsum(values):
- s = 0
- for x in values:
- s += x
- yield s
- # To get a list
- cumulative = list(cumsum(values))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement