Codington
0 of 6 problems solved • 0%

Exercise prompt

Measure the Labels

A for loop takes one value at a time from a list. Indent its body so Python knows which lines to repeat.

Example

Print a separate sign for each stop on a route.

stops = ["Elm", "Pine"] for stop in stops: print(f"Next: {stop}") # Next: Elm # Next: Pine

The first pass uses Elm and the second uses Pine. Instead of printing inside a loop, you can save a value each time with a list’s append method.

Your task

Finish the loop in the editor. Return a new list containing the length of each label, including blanks and repeated labels. For example, label_lengths(['Ox', '', 'Ox']) returns [2, 0, 2].