def pop(self) -> Any:
        # make sure the deque has elements to pop
        assert not self.is_empty(), "Deque is empty."

        topop = self._back
        self._back = self._back.prev_node  # set new back
        # drop the last node - python will deallocate memory automatically
        self._back.next_node = None

        self._len -= 1

        return topop.val