Using Lists as Queues : Queue « Data Structure « Python






Using Lists as Queues

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

           
       








Related examples in the same category