- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStack.py
More file actions
Latest commit
28 lines (21 loc) · 546 Bytes
/
Copy pathStack.py
File metadata and controls
28 lines (21 loc) · 546 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
classStack:
"""
This is a simple implementation of Stack
"""
pass
def__init__(self):
self.__items= []
defpush(self, item):
self.__items.append(item)
defpop(self):
ifnotself.is_empty():
returnself.__items.pop()
raiseStackEmptyException('stack is empty')
deflength(self):
returnlen(self.__items)
defis_empty(self):
ifnotlen(self.__items):
returnTrue
returnFalse
classStackEmptyException(Exception):
pass