Get startedGet started for free

Using Python's LifoQueue

In this exercise, you will work with Python's LifoQueue(). You will create a stack called my_book_stack to add books and remove them from it.

This exercise is part of the course

Data Structures and Algorithms in Python

View Course

Exercise instructions

  • Import the module that contains Python's LifoQueue().
  • Create an infinite LifoQueue().
  • Add an element to the stack.
  • Remove an element from the stack.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the module to work with Python's LifoQueue
import ____

# Create an infinite LifoQueue
my_book_stack = queue.____(____)

# Add an element to the stack
my_book_stack.____("Don Quixote")

# Remove an element from the stack
my_book_stack.____()
Edit and Run Code