Editor

Zip Names and Scores

#235 · Python idioms · Beginner · 30 XP · about 4 min

A quiz app keeps the players in one list and their scores in another, in the same order. Write make_scores(names, scores) that returns a dictionary mapping each name to its score.

  • The first name goes with the first score, the second with the second, and so on.
  • If one list is longer than the other, its extra items are ignored.
  • If a name appears more than once, its later score replaces the earlier one, and the name keeps the place where it first appeared.

Examples

make_scores(['Ana', 'Ben'], [90, 85])        # returns {'Ana': 90, 'Ben': 85}
make_scores(['Ana', 'Ben', 'Cy'], [90, 85])  # returns {'Ana': 90, 'Ben': 85}
make_scores(['Ana'], [70, 80, 90])           # returns {'Ana': 70}

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.