Comprehensions and functional programming · 12 / 15 Exercise Medium

The best student

Objective

Create a Python program that finds the student with the highest grade using max with key.

Instructions

  • Read an integer n and then n lines with the format name grade (the grade is an integer).
  • Store each student as a tuple (name, grade) in a list.
  • Get the one with the highest grade with max(students, key=lambda s: s[1]). If there is a tie, the first one is kept.
  • Show Best: name (grade).
Input
4
ana 7
luis 9
eva 5
marta 9
Output
Best: luis (9)

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise