Problem Description
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
Input:
First Line:Number of Elements in the List
Second Line:Elements of the List
Output:
Print the Resulting List after doing the cumulative sum.CODING ARENA
n= int(input())
a=input().split()
count=0
print("The new list is:");
for i in range(n):
count+=int(a[i])
print(count,end=" ")
Test Case 1
Input (stdin)5 1 2 3 4 5
Expected OutputThe new list is: 1 3 6 10 15
Test Case 2
Input (stdin)4 23 56 67 10
Expected OutputThe new list is: 23 79 146 156
No comments:
Post a Comment