Untitled

 avatar
unknown
plain_text
a year ago
425 B
5
Indexable
0. Implement Stack.
stack=[]
def push():
element=input("Enter a element:")
stack.append(element)
print(stack)
def pop_element():
if not stack:
print("Stack is Empty")
else:
e=stack.pop()
print("Removed Element is:",e)
print(stack)
while True:
print("Select Operation 1.Push 2.Pop 3.Quit")
choice=int(input())
if choice==1:
push()
elif choice==2:
pop_element()
elif choice==3:
break
else:
print("Enter the correct Operation.")
Editor is loading...
Leave a Comment