reduce python + code example
Example 1: reduce in python
'''try this'''
from functools import reduce
a = [1,2,3,4]
SUM = reduce(lambda n,n2:n+n2,a)
print(SUM)
Example 2: python reduce()
from functools import reduce
items = [1,2,3,4,5]
sum_all = reduce(lambda x,y: x + y, items)
print (sum_all) #15