Keep Each Player's Best

Python for AIMedium+10 XP+10

Keep Each Player's Best

A game logs every attempt in two lists that line up: who played, and what they scored. Players can appear many times.

Write best_scores(names, scores). It returns a dictionary of each player → their highest score.

Players appear in the dictionary in the order they first played. Empty lists give back an empty dictionary.

Careful: dict(zip(names, scores)) keeps each player's last score, which isn't always their best.

Examples

names = ["Ada", "Ben", "Ada"]
scores = [70, 50, 90]
returns {'Ada': 90, 'Ben': 50}
names = ["Cleo", "Cleo"]
scores = [80, 40]
returns {'Cleo': 80}

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run