Leaderboard Top Scorer

Easy ⏱ 8 min 72% acceptance ★★★★☆ 4.2
Write a function top_scorer(scores) that takes a dict mapping player names to integer scores and returns the name of the player with the highest score. Assume scores are unique.

Examples

Example 1
Input
top_scorer({'Ravi': 42, 'Meera': 88, 'Sam': 55})
Output
'Meera'
Explanation

Meera has the highest score, 88.

Constraints

  • scores is non-empty.
  • All values are unique.

Topics

Dictionariesleaderboard

Companies

ZomatoSwiggy

Hints

Hint 1

`max(scores, key=scores.get)` returns the key with the largest value.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.