Skip to main content

Repair the Stack

Challenge on lesson: Checkpoint: Test-First Repair

CHALLENGE
Difficulty: intermediate+25 XP

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.

Back to lesson: Checkpoint: Test-First Repair