-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
35 lines (29 loc) · 684 Bytes
/
stack.py
File metadata and controls
35 lines (29 loc) · 684 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
"""
Stack Data Structure.
"""
class Stack():
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def get_stack(self):
return self.items
def is_empty(self):
return self.items == []
def peek(self):
if not self.is_empty():
return self.items[-1]
#myStack = Stack()
#print(myStack.is_empty())
#myStack.push("A")
#myStack.push("B")
#print(myStack.get_stack())
#myStack.push("C")
#print(myStack.get_stack())
#myStack.pop()
#print(myStack.get_stack())
#print(myStack.is_empty())
#print(myStack.peek())
#print(myStack.get_stack())