Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 25, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save computer-tutor/d8f2793cee92a57476f10b720a1fa5ca to your computer and use it in GitHub Desktop.
Save computer-tutor/d8f2793cee92a57476f10b720a1fa5ca to your computer and use it in GitHub Desktop.
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