Answers for "reduce pythin"

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

Python Answers by Framework

Browse Popular Code Answers by Language