stack = []
def push():
element = input("Enter element to add (push): ")
[Link](element)
print(f"{element} added to stack.")
def pop_element():
if len(stack) == 0:
print("Stack is empty! Nothing to remove.")
else:
element = [Link]()
print(f"Removed element: {element}")
def show():
if len(stack) == 0:
print("Stack is empty.")
else:
print("Current Stack:")
for i in range(len(stack) - 1, -1, -1):
print(stack[i])
while True:
print("\nSTACK OPERATIONS MENU")
print("1. Add (Push)")
print("2. Remove (Pop)")
print("3. Show Stack")
print("4. Exit")
choice = input("Enter your choice (1-4): ")
if choice == '1':
push()
elif choice == '2':
pop_element()
elif choice == '3':
show()
elif choice == '4':
print("Stack operations completed.")
break
else:
print("Invalid choice! Please enter a number between 1 and 4.")
host=[]
ch='y'
def push(host):
rno=int(input("Enter Student Roll Number"))
name=input("Enter Student Name")
city=input("Enter City")
temp=[rno,name,city]
[Link](temp)
def pop(host):
if(host==[]):
print("No Record")
else:
print("Deleted Record is:",[Link]())
def display(host):
l=len(host)
print("Student Roll Number\t Student Name")
for i in range(l-1,-1,-1):
print(host[i])
while(ch=='y' or ch=="Y"):
print("1. Add Record\n")
print("2. Delete Record\n")
print("3. Display Record\n")
print("4. Exit")
op=int(input("Enter the Choice"))
if(op==1):
push(host)
elif(op==2):
pop(host)
elif(op==3):
display(host)
elif(op==4):
break