forked from RadiantCoding/Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStacks.py
35 lines (33 loc) · 840 Bytes
/
Stacks.py
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=[]
def view():
for x in range(len(stack)):
print(stack[x])
def push():
item = input ("Please enter the item you wish to add to the Stack: ")
stack.append(item)
def pop():
item = stack.pop(-1)
print("You just poped out: ",item)
def peek():
item = stack[-1]
print("You just peeked",item)
while True:
print("")
print("=======================")
print("1.View the Stack")
print("2.Push the Stack")
print("3.Pop the Stack")
print("4.Peek the Stack")
print("=======================")
print("")
choice = int(input("Please enter a menu choice: "))
if choice == 1:
view()
elif choice == 2:
push()
elif choice == 3:
pop()
elif choice==4:
peek()
else:
print("Input Incorrect")