id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

cumsum


Write a function called cumsum that takes a list of numbers and returns the cumulative sum; that is, a new list where the ith element is the sum of the first i+1 elements from the original list. For example: >>> t = [1, 2, 3] >>> cumsum(t) [1, 3, 6]


cumsum([1, 2, 3]) → [1, 3, 6]
cumsum([3, 2, 1]) → [3, 5, 6]
cumsum([2, 1, 3]) → [2, 3, 6]

...Save, Compile, Run (ctrl-enter)

def cumsum(t):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 102 Post-solution available

Copyright Nick Parlante 2017 - privacy