Python Queue

from collections import deque

queue = deque([10, 20, 30])

queue.append(40)      # apppend data at the right side     
queue.append(50)      # apppend data at the right side
queue.appendleft(5)   # apppend data at the left side
print("After Insertion ata:")
for i in range(len(queue)):
    print(queue[i], end=" ")


print("\nAfter removing Data")         
queue.popleft()        # data deleted from the left side         
for i in range(len(queue)):
    print(queue[i], end=" ")

 

Leave a Reply

Your email address will not be published. Required fields are marked *