Solution Review : Return Key With a Maximum Value

This lesson will explain how to find a key with a maximum value.

We'll cover the following

Solution: Use max() Function

  • Create a list containing values and another list containing keys.
  • Get the maximum index of values using the max() built-in function. Then, using key[value.index(max(value))], get the key corresponding to the maximum value.

The following python code illustrates the concept.

Get hands-on with 1000+ tech skills courses.