30 seconds of python

  Back to Home

max_by

mathlistfunctionbeginner

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.

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