# accumulate sum of elements in list import itertools # import python module itertools st1 = [ 1, 2, 3, 4, 5 ] sum_list = itertools.accumulate(st1) # accumulate sum of elements print(list(sum_list)) # [ 1, 3, 6, 10, 15 ]