- Related Questions & Answers
- Write a program to form a cumulative sum list in Python
- Python Program to Find the Cumulative Sum of a List where the ith Element is the Sum of the First i+1 Elements From The Original List
- Python program to find sum of elements in list
- Find sum of elements in list in Python program
- Program to find largest sum of non-adjacent elements of a list in Python
- Python Program to Find the Total Sum of a Nested List Using Recursion
- How to find sum a list of numbers in Python?
- Python program to find sum of absolute difference between all pairs in a list
- Program to find sum of non-adjacent elements in a circular list in python
- Cumulative sum of elements in JavaScript
- Program to find maximum sum of popped k elements from a list of stacks in Python
- Program to find sum of widths of all subsequences of list of numbers in Python
- Program to find sum of minimum trees from the list of leaves in python
- Program to find diagonal sum of a matrix in Python
- Python Program to find the sum of array

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given a list, we need to create a list with the cumulative sum.

Now let’s observe the solution in the implementation below −

# cumulative sum def Cumulative(l): new = [] cumsum = 0 for element in l: cumsum += element new.append(cumsum) return new # Driver Code lists = [10, 20, 30, 40, 50] print ("New list:",Cumulative(lists))

New list: [10, 30, 60, 100, 150]

All the variables are declared in the local scope and their references are seen in the figure above.

In this article, we have learned about how we can make a Python program to find the Cumulative sum of a list.

Advertisements