diff --git a/Project 5/Stack.py b/Project 5/Stack.py index c4b7c06..f70543a 100644 --- a/Project 5/Stack.py +++ b/Project 5/Stack.py @@ -47,7 +47,9 @@ class Stack[T]: Raises: EmptyError exception if the stack is empty ''' - pass + if self.is_empty(): + raise EmptyError("Stack is empty") + return self._data.remove_head() def peek(self) -> T: ''' returns the topmost element from the stack without modifying the stack @@ -56,7 +58,9 @@ class Stack[T]: Raises: EmptyError exception if the stack is empty ''' - pass + if self.is_empty(): + raise EmptyError("Stack is empty") + return self._data.get_head() def is_empty(self) -> bool: ''' indicates whether the stack is empty