about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 102 Post-solution available
Copyright Nick Parlante 2017 - privacy