Skip to main content

Repair the Stack

Challenge on lesson: Checkpoint: Test-First Repair

The class Stack below has THREE bugs: pop on empty must raise IndexError (it returns None), peek must not remove the item (it does), and size must reflect the count (it miscounts). Fix the class so all behaviors hold. Do not rename anything.

Difficulty: intermediate

Back to lesson: Checkpoint: Test-First Repair