Sample implementation of stack in python using list.
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
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