Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 18, 2020 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/11d1b5685852e1228eee22855434af4c to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/11d1b5685852e1228eee22855434af4c to your computer and use it in GitHub Desktop.
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