Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Created March 7, 2020 05:35
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 amalgjose/2a69e166344119ceb8f2c023f49957f4 to your computer and use it in GitHub Desktop.
Save amalgjose/2a69e166344119ceb8f2c023f49957f4 to your computer and use it in GitHub Desktop.
Sample implementation of stack in python using list.
my_first_stack = []
# Push elements to stack using append()
my_first_stack.append('edward')
my_first_stack.append('sabitha')
print('My First Stack')
print(my_first_stack)
#Retrieve elements from the stack
print('\nElements retrieved from the stack:')
print(my_first_stack.pop())
print(my_first_stack.pop())
#Now print the stack and see the remaining elements
print(my_first_stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment