Who Came Third?

Data with PythonMedium+10 XP+10

Who Came Third?

A fun run records each runner's finishing time in minutes. The results are stored in the order people signed up, not the order they finished.

Task: write nth_place(runners, times, n) that returns the name of the runner who finished in place n.

  • runners and times are lists of the same length. times[i] belongs to runners[i].
  • Build a DataFrame with a runner column and a time column.
  • The lowest time is 1st place, the next lowest is 2nd place, and so on.
  • n counts from 1, and is always between 1 and the number of runners.
  • No two runners have the same time.

Examples

runners = ["Ana", "Ben", "Cara", "Dev"]
times = [31.5, 27.2, 29.8, 35.0]
n = 1
returns 'Ben'
runners = ["Ana", "Ben", "Cara", "Dev"]
times = [31.5, 27.2, 29.8, 35.0]
n = 3
returns 'Ana'

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