-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
39 lines (32 loc) · 771 Bytes
/
stack.py
File metadata and controls
39 lines (32 loc) · 771 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
29
30
31
32
33
34
35
36
37
38
39
from linkedlist import LinkedList
class Stack:
def __init__(self):
self.list = LinkedList()
def push(self, obj):
"""
Push an object onto the top of the stack
Parameters
----------
obj: object
Object to push on
"""
## TODO: Fill this in
def pop(self):
"""
Pop the object from the top of the stack, or
return None if the stack is empty
Returns
-------
object:
Object at the top of the list
"""
ret = None
## TODO: Fill this in
return ret
if __name__ == '__main__':
s = Stack()
s.push("A")
s.push("B")
s.push("C")
for i in range(3):
print(s.pop())