Bug hunt

Tidy the Keeper's Code

PEP 8 is Python's style guide. Following it means any Python developer can read your code without stumbling. The naming rules matter most:

Thing Style Example
variables, functions, methods, modules snake_case total_fuel
classes CapWords LanternKeeper
constants UPPER_SNAKE_CASE MAX_FUEL
internal names leading _ _cache

Plus: 4-space indents, one statement per line, spaces around = and operators, and imports at the top. Teams let tools enforce this: ruff or black format and lint code automatically.

The bug report

A teammate's class works... sort of. When Ada and Bo each add lanterns, Ada's total includes Bo's fuel! The culprit: Lanterns = [] is written in the class body, so it's a class attribute shared by every keeper. Per-object data belongs in __init__, as self.lanterns = [].

Assignment

  1. Fix the bug: give each keeper its own lanterns list.
  2. Rename to PEP 8 style: maxFuel becomes MAX_FUEL, lantern_keeper becomes LanternKeeper, Name becomes name (the parameter and the attribute), Lanterns becomes lanterns, AddLantern becomes add_lantern, TotalFuel becomes total_fuel.
  3. Put each statement on its own line.