""" This implementation of the Deque ADT comes from Problem Solving with Algorithms and Data Structures using Python 3rd Edition Miller, Ranum, and Yasinovskyy It is constructed utilizing the built in Python list and considering the rear to be to the "left" or "top" end of the list and the front to be to the the "right" or "bottom" end of the list. """ class Deque: """Deque implementation as a list""" def __init__(self): """Create new deque""" self._items = [] def is_empty(self): """Check if the deque is empty""" return not bool(self._items) def add_front(self, item): """Add an item to the front of the deque""" self._items.append(item) def add_rear(self, item): """Add an item to the rear of the deque""" self._items.insert(0, item) def remove_front(self): """Remove an item from the front of the deque""" return self._items.pop() def remove_rear(self): """Remove an item from the rear of the deque""" return self._items.pop(0) def size(self): """Get the number of items in the deque""" return len(self._items) In remove_front we use the pop method to remove the