-
-
Save IndhumathyChelliah/11d1b5685852e1228eee22855434af4c 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
stack=[1,2,3,4] | |
#adding elements to top of stack | |
stack.append(5) | |
print (stack)#Output:[1, 2, 3, 4, 5] | |
stack.append(6) | |
print (stack)#Output:[1, 2, 3, 4, 5, 6] | |
#removing elements from top of stack | |
#pop() will remove and return the top element | |
print (stack.pop())#Output: 6 | |
print (stack.pop())#Output: 5 | |
print (stack)#Output: [1,2,3,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment