ues queue or lists for queue python code example
Example: python list as queue
# Demonstrate queue implementation using list
# Initializing a queue
queue = []
# Adding elements to the queue
queue.append('a')
queue.append('b')
print(queue)
# Removing elements from the queue
print("\nElements dequeued from queue")
print(queue.pop(0))
print(queue.pop(0))
print("\nQueue after removing elements")
print(queue)
# print(queue.pop(0)) will raise and IndexError as the queue is now empty