Q. Cumulative sum of a list [a, b, c...] is defined as [a, a + b, a + b + c, ...). Write a program to input a list of number and then create another list from this list that contains cumulative sum of numbers in list1.

 

Answer = 


lst = eval(input ("Enter the List :- "))
lst1 = [  ]
sum = 0
for i in lst :
    sum += i
    lst1 += [ sum ]
print(lst1)

 

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post