Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2020 06:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Stack implementation in python using Queue
from queue import LifoQueue as lq
# Initializing a stack with max size as 2
sample_stack = lq(maxsize=2)
# The qsize() function shows the size of the stack
# Now lets push some elements to stack
# put() will push elements to stack
# Retrieve the elements from the stack
print('\nRetrieved elements from Stack in LIFO order')
print("\nIs the stack empty ? : ", sample_stack.empty())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment