File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 8
8
It needs no parameters and returns the item. The stack is modified.
9
9
peek() returns the top item from the stack but does not remove it.
10
10
It needs no parameters. The stack is not modified.
11
- isEmpty () tests to see whether the stack is empty.
11
+ is_empty () tests to see whether the stack is empty.
12
12
It needs no parameters and returns a boolean value.
13
- size() returns the number of items on the stack.
14
- It needs no parameters and returns an integer.
15
13
"""
16
14
from abc import ABCMeta , abstractmethod
17
15
class AbstractStack (metaclass = ABCMeta ):
@@ -72,15 +70,15 @@ def push(self, value):
72
70
73
71
def pop (self ):
74
72
if self .is_empty ():
75
- raise IndexError ("stack is empty" )
73
+ raise IndexError ("Stack is empty" )
76
74
value = self ._array [self ._top ]
77
75
self ._top -= 1
78
76
return value
79
77
80
78
def peek (self ):
81
79
"""returns the current top element of the stack."""
82
80
if self .is_empty ():
83
- raise IndexError ("stack is empty" )
81
+ raise IndexError ("Stack is empty" )
84
82
return self ._array [self ._top ]
85
83
86
84
def _expand (self ):
You can’t perform that action at this time.
0 commit comments