Calculate List Cumulative Sum

Discover how to compute a list's cumulative sum using Python.

The goal of this exercise is to strengthen your skills with Python list manipulations. Develop a function named `cumulative_sum`, which should accept a list of numerals as an argument and yield a new list of the same length. Each element in the resultant list should represent the cumulative sum at that index in the input list, inclusive of all the previous elements. This function should be applicable to all types of numbers, negatives included. ### Parameters - `numbers`: A list of integers (`numbers`) – input for which the cumulative sum is calculated. ### Return Value - A list of integers symbolizing the cumulative sum corresponding to each index in the input list. ### Examples ```python # [1] + [1 + 2] + [1 + 2 + 3] cumulative_sum([1, 2, 3]) ➞ [1, 3, 6] # [1] + [1 - 2] + [1 - 2 + 3] cumulative_sum([1, -2, 3]) ➞ [1, -1, 2] # [3]+[3+3]+[3+3-2]+[3+3-2+408]+[3+3-2+408+3]+[3+3-2+408+3+3] cumulative_sum([3, 3, -2, 408, 3, 3]) ➞ [3, 6, 4, 412, 415, 418] ```