Using List as Queue in Python

This Python script will show you how to use List in Python as a Queue

Source code :

queue = ["Apple", "Google", "Twitter"]

queue.append("Facebook") #Appending Facebook to the Queue

print(queue)

popped = queue.pop(0)

print("Popped from queue : " , popped)

popped = queue.pop(0)

print("Popped from queue : " , popped)

print(queue)



Output :

['Apple', 'Google', 'Twitter', 'Facebook']
Popped from queue :  Apple
Popped from queue :  Google
['Twitter', 'Facebook']

Output :


                

Comments :