1class Stack:
2 def __init__(self):
3 self._data = []
4
5 def push(self, value):
6 self._data.append(value)
7
8 def pop(self):
9 return self._data.pop()
10
11 def peek(self):
12 return self._data[-1]
no lines flagged
#006PracticeEasy8 min · 50 XP
Stack Underflow Not Handled
This stack implementation crashes when pop() is called on an empty stack. Identify the missing guard.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.