Codington
0 of 6 problems solved • 0%

Exercise prompt

Find the Next Stop

Python indexes the first item at zero. A list is false in a condition when it is empty.

Example

A concert poster shows the headline act and the final act.

acts = ["Mira", "Léo", "Ada"] print(acts[0], acts[-1]) # Mira Ada

Index 0 reads the first entry and -1 reads the last. Both need at least one entry, so check an uncertain list before indexing.

Your task

Return the first stop from next_stop(stops), or None if no stops remain. Leave the input list intact.

next_stop(["Gate", "Hall"]) # "Gate" next_stop([]) # None