Mega Code Archive

 
Categories / Python / Data Structure
 

Using Lists as Queues

# To add an item to the back of the queue, use append(). To retrieve an item  # from the front of the queue, use pop() with 0 as the index. For example: queue = ["A", "B", "C"] queue.append("D")           queue.append("E")           print queue.pop(0) print queue.pop(0) print queue