Skip to content

Commit

Permalink
fixed peek() method of the ArrayStack
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bender committed Mar 25, 2018
1 parent ea43887 commit f92c5e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stack/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ def pop(self):
return value

def peek(self):
"""
returns the current top element of the stack.
"""
if self.isEmpty():
raise IndexError("stack is empty")
return self.array[self.top]
return self.array[self.top -1]

def expand(self):
"""
Expand Down

0 comments on commit f92c5e3

Please sign in to comment.