Answers for "reduce function in python with examples"

7

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
Posted by: Guest on May-09-2020

Code answers related to "reduce function in python with examples"

Python Answers by Framework

Browse Popular Code Answers by Language