Using Lists as a Queue : Queue : Collections PYTHON TUTORIALS


PYTHON TUTORIALS » Collections » Queue »

 

Using Lists as a Queue


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()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Collections
» Queue