Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

accumulate sum of elements in list

# 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 ]
 
PREVIOUS NEXT
Tagged: #accumulate #sum #elements #list
ADD COMMENT
Topic
Name
4+9 =