Returns the maximum value of a list in Python

PHOTO EMBED

Mon Mar 23 2020 07:13:49 GMT+0000 (Coordinated Universal Time)

Saved by @0musicon0 #python #python #math #list

def max_by(lst, fn):
  return max(map(fn, lst))
content_copyCOPY

Returns the maximum value of a list, after mapping each element to a value using the provided function. Use map() with fn to map each element to a value using the provided function, use max() to return the maximum value.

https://www.30secondsofcode.org/python/s/max-by/