Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

reduce in python

from functools import reduce
# import reduce function 
scores = [66, 75, 102, 15, 510]
# have alist of scores we need to do funcion
total = reduce(lambda a, b: a + b, scores)
# we take evry item from list as a,b and sum of them
# plus evry tow items to other items
print(int(f"total is {total}"))
#total is 768
#print total as integer
 
PREVIOUS NEXT
Tagged: #reduce #python
ADD COMMENT
Topic
Name
7+2 =