Remove and return the top element. Returns: The top (largest) element. Raises: IndexError: If the stack is empty.
(self)
| 64 | self._push_direct(temp_stack.pop()) |
| 65 | |
| 66 | def pop(self) -> int: |
| 67 | """Remove and return the top element. |
| 68 | |
| 69 | Returns: |
| 70 | The top (largest) element. |
| 71 | |
| 72 | Raises: |
| 73 | IndexError: If the stack is empty. |
| 74 | """ |
| 75 | if self.is_empty(): |
| 76 | raise IndexError("Stack is empty") |
| 77 | return self.items.pop() |
| 78 | |
| 79 | def peek(self) -> int: |
| 80 | """Return the top element without removing it. |