def push():
element=int(input("Enter an element"))
stack.append(element)
print("Element added successfully\n")
def pop():
if stack==[]:
print("Stack is empty\n")
else:
print("Deleted element is",stack.pop())
print()
def peek():
if stack==[]:
print("Stack is empty-No top element\n")
else:
print("Top element is",stack[len(stack)-1])
print()
def display():
if stack==[]:
print("Stack is empty\n")
else:
print("The stack is :")
for i in range(len(stack)-1,-1,-1):
print(stack[i])
print()
#__main__
stack=[]
while True:
print("STACK OPERATIONS")
print("1. Push")
print("2. Pop")
print("3. Peek")
print("4. Display Stack")
print("5. Exit")
choice=int(input("Enter your choice\n"))
if choice==1:
push()
elif choice==2:
pop()
elif choice==3:
peek()
elif choice==4:
display()
elif choice==5:
print("Thank You!!!")
break
else:
print("Choice must be between 1-5\n")
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
4
Stack is empty
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
1
Enter an element34
Element added successfully
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
1
Enter an element65
Element added successfully
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
4
The stack is :
65
34
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
3
Top element is 65
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
2
Deleted element is 65
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
4
The stack is :
34
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display Stack
5. Exit
Enter your choice
5
Thank You!!!