Created
April 25, 2020 08:55
-
-
Save computer-tutor/d8f2793cee92a57476f10b720a1fa5ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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