import queue
pile = queue.LifoQueue()

for i in range(5): pile.put(i)

while not pile.empty(): 
  print(pile.get(), end=" ")

# 4 3 2 1 0