i have got a list like this in Python:
List [1, 41, 6, 1, 41, 13]
now i want to add the elements and want to write it in a new list like this:
newList [42, 48, 49, 90, 103]
i hope someone can help me
thanks
i have got a list like this in Python:
List [1, 41, 6, 1, 41, 13]
now i want to add the elements and want to write it in a new list like this:
newList [42, 48, 49, 90, 103]
i hope someone can help me
thanks
With numpy.cumsum
:
>>> import numpy as np
>>> lst = [1, 41, 6, 1, 41, 13]
>>> list(np.cumsum(lst)[1:])
[42, 48, 49, 90, 103]