
Checkpoint
Checkpoint: Harbor Radio
The harbor radio prints one message per line. The dock crew types fast, so capitals are all over the place:
ship WREN docks at pier 4
SHIP heron Docks At Pier 12
storm warning, every ship docks at pier 1 later
ship Kite docks at pier 7
Only lines that start with ship are real dockings. The storm
line mentions a pier, but it is not a docking.
This checkpoint mixes the chapter's spells: classes and quantifiers,
capture groups, re.sub with a function, and the MULTILINE and
IGNORECASE flags.
Assignment
dockings(log)returns a list of(ship, pier)tuples, one per docking line, in order. A docking line is a whole line shaped likeship NAME docks at pier NUMBER, in any letter case. Title-case the ship name ("WREN"becomes"Wren") and make the pier anint.hide_piers(log)replaces every pier number (the digits after the wordpier, any case) with one#per digit, sopier 12becomespier ##. Keep the wordpierexactly as it was typed. Usere.subwith a function.
dockings(log)returns a list of(ship, pier)tuples, one per docking line, in order. A docking line is a whole line shaped likeship NAME docks at pier NUMBER, in any letter case. Title-case the ship name ("WREN"becomes"Wren") and make the pier anint.hide_piers(log)replaces every pier number (the digits after the wordpier, any case) with one#per digit, sopier 12becomespier ##. Keep the wordpierexactly as it was typed. Usere.subwith a function.
main.py Python sleeping
Press Run to try your code, then Check to test it.