Using the stack class >>> s = Stack() >>> s.push("one") >>> s.push("two") >>> s.stack ['one', 'two'] >>> s.pop() 'two' >>> s.pop() 'one' >>> s.pop() Traceback (innermost last): File "", line 1, in ? s.pop() File "", line 9, in pop return self.stack.pop() IndexError: pop from empty list