Skip to main content
  • Python is available now. All other compilers are coming soon.

    Python
  • Popular Tutorials

    • Getting Started With Python
    • Python if Statement
    • while Loop in Python
    • Python Lists
    • Dictionaries in Python
    All Python Tutorials

    Reference Materials

    Built-in FunctionsList MethodsDictionary MethodsString Methods
    View all

Online Compilers

  • Python Compiler
  • Python Playground
  • Python Projects
  • Exercises

Tutorials

  • Learn Python
  • Python for Beginners
  • Variables and Types
  • Python Strings
  • Python Lists
  • Python If Else
  • Python For Loops
  • Python Functions
  • Python Classes

Examples

  • Python Examples
  • Hello World
  • Add Two Numbers
  • Even or Odd
  • Factorial
  • Fibonacci
  • Prime Check
  • Palindrome Check

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Use
  • Disclaimer

© 2026 ILoveCompiler. All rights reserved.

  1. Home
  2. Python Exercises
  3. Highest Score

Dictionaries and counting · Python exercise

Highest Score

Read names and scores, then print the highest-scoring student.

intermediate3 testsdictionariesparsingmaximum

Problem

The first line contains n. The next n lines each contain a name and an integer score separated by a space. Print the name and score of the highest-scoring student. If several students tie, choose the one that appears first.

Input and output

Input
n followed by n lines of name and score.
Output
The chosen name and score separated by a space.

Constraints

  • 1 ≤ n ≤ 1,000. Names contain no spaces.

Examples

Example 1

Input

3
Ada 90
Grace 95
Linus 88

Output

Grace 95

Example 2

Input

2
Sam 70
Alex 70

Output

Sam 70

Sam appears first.

How testing works

Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.

Your solution3 hidden input checks

Loading editor…

Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.

Related exercises

intermediate

Word Frequency

Count each word in a line and print the counts alphabetically.

3 tests
intermediate

Character Frequency

Count non-space characters in a line and print a sorted table.

3 tests
Previous exerciseCharacter Frequency