when the dequeue method is calledthe current value of self front designates the index of the value that is to be removed and returned we keep local reference to the element that will be returnedsetting answer self data[self frontjust prior to removing the reference to that object from the listwith the assignment self data[self frontnone our reason for the assignment to none relates to python' mechanism for reclaiming unused space internallypython maintains count of the number of references that exist to each object if that count reaches zerothe object is effectively inaccessiblethus the system may reclaim that memory for future use (for more detailssee section since we are no longer responsible for storing dequeued elementwe remove the reference to it from our list so as to reduce that element' reference count the second significant responsibility of the dequeue method is to update the value of front to reflect the removal of the elementand the presumed promotion of the second element to become the new first in most caseswe simply want to increment the index by onebut because of the possibility of wrap-around configurationwe rely on modular arithmetic as originally described on page resizing the queue when enqueue is called at time when the size of the queue equals the size of the underlying listwe rely on standard technique of doubling the storage capacity of the underlying list in this wayour approach is similar to the one used when we implemented dynamicarray in section howevermore care is needed in the queue' resize utility than was needed in the corresponding method of the dynamicarray class after creating temporary reference to the old list of valueswe allocate new list that is twice the size and copy references from the old list to the new list while transferring the contentswe intentionally realign the front of the queue with index in the new arrayas shown in figure this realignment is not purely cosmetic since the modular arithmetic depends on the size of the arrayour state would be flawed had we transferred each element to its same index in the new array = figure resizing the queuewhile realigning the front element with index