.reduce python code example
Example 1: python reduce()
#max num in list
from functools import reduce
items = [1, 24, 17, 14, 9, 32, 2]
all_max = reduce(lambda a,b: a if (a > b) else b, items)
print (all_max) # 32
Example 2: reduce in python
'''try this'''
from functools import reduce
a = [1,2,3,4]
SUM = reduce(lambda n,n2:n+n2,a)
print(SUM)