-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStacksAsList.py
More file actions
26 lines (25 loc) · 803 Bytes
/
StacksAsList.py
File metadata and controls
26 lines (25 loc) · 803 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
###################################
# Implrenting list as stacks #
# Pythom Code #
# Coded by Harsh Tiwari #
###################################
l1=[] # Empty List
c="y" # Condition for while
while (c=="y"):
print("1. Push \n 2.Pop \n 3.Display")
choice=int(input("Enter your choice"))
if choice==1:
a=input("Enter any no.")
l1.append(a)
elif choice==2:
if l1==[]:
print("Your stack is empty")
else :
print("Deleted the element is ",l1.pop())
elif choice==3:
d=len(l1)
for i in range (d-1,-1,-1):
print("the list is ", l1[i])
else :
print("U have wntered the wrong choice ")
c=input("Do u want to continue ")# if the user enter y then it restarts