1 point

Returns the maximum value of a list in Python


dashboard

Mon Mar 23 2020 07:13:49 GMT+0000 (UTC)

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

def max_by(lst, fn):
  return max(map(fn, lst))
content_copy Copy

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/