
Checkpoint
Checkpoint: The Watch Log
Every night, the lighthouse keepers write what happened in a watch log. Most entries are written at 20:00 by Pip, so those should be the defaults.
This checkpoint uses the whole chapter: default values,
keyword arguments, and the safe None default for lists.
Assignment
- Give
log_linethe defaultshour=20andkeeper="Pip". It returnsf"{hour}:00 {event} ({keeper})". Solog_line("Lit the lamp")gives"20:00 Lit the lamp (Pip)". - Fix
add_line(line, log). It appendslinetologand returns the log. When no log is passed, it must start a new empty list every time. Right now, every call shares one list!
- Give
log_linethe defaultshour=20andkeeper="Pip". It returnsf"{hour}:00 {event} ({keeper})". Solog_line("Lit the lamp")gives"20:00 Lit the lamp (Pip)". - Fix
add_line(line, log). It appendslinetologand returns the log. When no log is passed, it must start a new empty list every time. Right now, every call shares one list!
main.py Python sleeping
Press Run to try your code, then Check to test it.