Checkpoint

Checkpoint: The Lamplighter's Cart

Every evening the lamplighters roll their carts across the bridges, loaded with fresh lamps. The Guild wants a Cart class to keep track of them.

This checkpoint uses the whole chapter: __init__, methods, self, a class attribute, __str__ and __repr__.

Assignment

Complete the Cart class:

  1. __init__(self, owner) stores owner and gives every cart its own empty lamps list.
  2. Each new cart adds 1 to the class attribute Cart.built.
  3. load(lamp) adds lamp to the end of lamps and returns how many lamps the cart now holds.
  4. unload() removes the last lamp and returns it. If the cart is empty, it returns None.
  5. __str__ returns text like Ada's cart: 2 lamps.
  6. __repr__ returns text like Cart('Ada').