class queue(): # Constructs an empty queue def __init__(self): self.L = [] self.start = -1 # initialize start to point to before the first valid index # Enqueue appends items at back of list def enqueue(self, item): self.L.append(item) # If the queue was empty prior to this insertion, update start if self.start == -1: self.start = self.start + 1 # Dequeue removes items from front of list. This method is not efficient def dequeue(self): self.start = self.start + 1 item = self.L[self.start - 1] return item # Shows the queue as a list def __repr__(self): return str(self.L[self.start:]) # Queue is empty is there if the list if physically empty # or start points to the end of the list def isEmpty(self): return len(self.L) == 0 or self.start == len(self.L)