What is Queue?

<aside> 💡 Queue is a linier structure that enable the insertion of element in one of the edges and the removal on the other edge.

</aside>

Untitled

Above it is a First in First Out (FIFO) methodology. The edge that enables the removal that is known as a part of the front of Queue and the other edges is recognized as the back of the edge from Queue.

Practice

queue = ['first', 'second', 'third']
print(queue)

print()

# pushing elements
queue.append('fourth')
queue.append('fifth')
print(queue)
print()

# printing heada
print(queue[0])

# printing tail
n = len(queue)
print(queue[n-1])
print()

# poping element
queue.remove(queue[0])
print(queue)
['first', 'second', 'third']

['first', 'second', 'third', 'fourth', 'fifth']

first
fifth

['second', 'third', 'fourth', 'fifth']

Note: len() → len refers to length.