def cumulative_sum(L):
retL = []
sum = 0
for e in L:
sum += e
retL.append(sum)
return retL
L = [1,2,3]
print cumulative_sum(L)
cumulative sum
最新推荐文章于 2024-01-23 07:30:00 发布
def cumulative_sum(L):
retL = []
sum = 0
for e in L:
sum += e
retL.append(sum)
return retL
L = [1,2,3]
print cumulative_sum(L)