import numpy as np y = [0, 1, 2, 3, 4, 5] np.cumsum(y) #Cumulative sum is output as ndarray # [ 0 1 3 6 10 15] np.cumsum(y).tolist() #Can also be a list # [0, 1, 3, 6, 10, 15]
Updating from time to time
Recommended Posts