I'm accumulating values in a list so that a value is the sum of all previous values, using np.cumsum():
l=[4,2,1,3]
c = np.cumsum(l)
print(c)
[4 6 7 10]
But I'd like to also add 1
to every computation, so that the result looks like:
[4 7 9 13]
What's the simplest way to achieve that?
CodePudding user response:
Here you go:
res = c np.arange(len(c))