Write a programExercise 4/4Intermediate30 XP

Total points and ranking

Task

The program reads lines of name points (the points are whole numbers) until an empty line comes. If a name repeats, its points add up. At the end it prints the ranking - each name with its total as name: points, from the highest total. On equal totals the names go in alphabetical order.

For the input

Ema 10
Adam 7
Ema 5
Boris 15

(and an empty line) the program prints

Boris: 15
Ema: 15
Adam: 7

Examples

  • Input

    Ema 10
    Adam 7
    Ema 5
    Boris 15

    Expected output

    Boris: 15
    Ema: 15
    Adam: 7

After you submit, 4 hidden tests will also check your solution: everyone equal, one name with zero, adding up overtakes, more repeats.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.