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

  1. dockings(log) returns a list of (ship, pier) tuples, one per docking line, in order. A docking line is a whole line shaped like ship NAME docks at pier NUMBER, in any letter case. Title-case the ship name ("WREN" becomes "Wren") and make the pier an int.
  2. hide_piers(log) replaces every pier number (the digits after the word pier, any case) with one # per digit, so pier 12 becomes pier ##. Keep the word pier exactly as it was typed. Use re.sub with a function.