-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdedpol.py
38 lines (35 loc) · 821 Bytes
/
dedpol.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
36
37
38
#Implement Stack Data Structure.
s = []
def push():
if len(s) == size:
print("Stack is Full")
else:
item = input("Enter the element:")
s.append(item)
def pop():
if(len(s) == 0):
print("Stack is Empty")
else:
item = s[-1]
del(s[-1])
print("The deleted element is:",item)
def display():
size = len(s)
if(size== 0):
print("Stack is Empty")
else:
for i in reversed(s):
print(i)
#Execution starts here
size=int(input("Enter the size of Stack:"))
while(True):
choice = int(input("1-Push 2-POP 3-DISPLAY 4-EXIT Enter your choice:"))
if(choice == 1):
push()
elif(choice == 2):
pop()
elif(choice == 3):
display()
else:
break
print ("Stack Data Structures")