MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Data Structures and Algorithms in Python

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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 dan Jalankan Kode