queue = []
def enQ():
queue.append("A")
def deQ():
if len(queue) == 0:
print 'Cannot pop from an empty queue!'
else:
print 'Removed [', 'queue.pop(0)', ']'
def viewQ():
print queue # calls str() internally
enQ()
viewQ()
deQ()
viewQ()
9.2.queue |
| 9.2.1. | Using Lists as a Queue |