def hotPotato(namelist, num): simqueue = Queue() for name in namelist: simqueue.enqueue(name) while simqueue.size() > 1: for i in range(num): simqueue.enqueue(simqueue.dequeue()) simqueue.dequeue() return simqueue.dequeue()
from pyqueue import Queue q=Queue() q.enqueue(6) q.enqueue('cat') q.enqueue(True) print(q.size()) print(q.dequeue()) print(q.dequeue()) print(q.size())