""" Queue class """

class Queue:
    """ A simple implementation of a FIFO queue. """
    def __init__(self):
        """ Initialize the queue. """
        self._items = [] # this means that we are going to implement the QUEUE with a LIST

    def __len__(self):
        """ Return the number of items in the queue. """
        return len(self._items)

    def __iter__(self):
        """ Create an iterator for the queue. """
        for item in self._items:
            yield item

    def __str__(self):
        """ Return a string representation of the queue. """
        return str(self._items)

    def enqueue(self, item):
        """ Add item to the queue. """
        self._items.append(item)

    def dequeue(self):
        """ Remove and return the least recently inserted item (FIFO). """
        return self._items.pop(0)

    def clear(self):
        """ Remove all items from the queue. """
        self._items = []


class Stack: # this class has the same method names, but it behaves as a STACK
    """ A simple implementation of a LIFO queue. """
    def __init__(self):
        """ Initialize the queue. """
        self._items = [] # this means that we are going to implement the QUEUE with a LIST

    def __len__(self):
        """ Return the number of items in the queue. """
        return len(self._items)

    def __iter__(self):
        """ Create an iterator for the queue. """
        for item in self._items:
            yield item

    def __str__(self):
        """ Return a string representation of the queue. """
        return str(self._items)

    def enqueue(self, item):
        """ Add item to the queue. """
        self._items.append(item)

    def dequeue(self):
        """ Remove and return the most recently inserted item (LIFO). """
        return self._items.pop()

    def clear(self):
        """ Remove all items from the queue. """
        self._items = []