Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def push(stack,x):
stack.append(x)
def pop(stack):
return stack.pop()
l=[4,5,6,7]
ans=int(input("Enter your choice:\n1:Press 1 to Push \n2:Press 2 to Pop\n Your Option:"))
if ans==1:
n=int(input("Enter element to push on stack:"))
push(l,n)
print(l)
elif ans==2:
pop(l)
print("The last entered element was popped!",)
print(l)
else:
print("Invalid Choice! Try again")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment