"""Python implementation for doubly-linked list data structure."""


class DoublyLinkedList(object):
    """Sets properties and methods of a doubly-linked list."""

    def __init__(self):
        """Create new instance of DoublyLinkedList."""
        self.tail = None
        self.head = None
        self._length = 0

    def push(self, val=None):
        """Instantiate and push new node."""
        if val is None:
            raise ValueError('You must give a value.')
        new_node = Node(val, self.head)
        if self.head is None:
            self.head = new_node
            self.tail = new_node
            new_node.next_node = None
            self._length += 1
            return
        self.head.prev_node = new_node
        self.head = new_node
        self._length += 1

    def append(self, val=None):
        """Instantiate and append new node."""
        if val is None:
            raise ValueError('You must give a value.')
        new_node = Node(val, None, self.tail)
        if self.head is None:
            self.head = new_node
            self.tail = new_node
            new_node.prev_node = None
            self._length += 1
            return
        self.tail.next_node = new_node
        self.tail = new_node
        self._length += 1

    def pop(self):
        """Remove and return node from head of doubly linked list."""
        current_node = self.head
        if current_node is None:
            raise IndexError('Nothing to pop.')
        if current_node.next_node is not None:
            self.head = current_node.next_node
            self.head.prev_node = None
        else:
            self.head = None
            self.tail = None
        self._length -= 1
        return current_node

    def shift(self):
        """Remove and return node from tail of doubly linked list."""
        current_node = self.tail
        if current_node is None:
            raise IndexError('Nothing to shift.')
        if current_node.prev_node is not None:
            self.tail = current_node.prev_node
            self.tail.next_node = None
        else:
            self.head = None
            self.tail = None
        self._length -= 1
        return current_node

    def remove(self, val):
        """Find and remove the first Node with a given value."""
        current_item = self.head
        while current_item.val != val:
            current_item = current_item.next_node
            if current_item is None:
                raise ValueError('Node not in doubly linked list.')
        if current_item.prev_node is None:
            self.head = current_item.next_node
            self.head.prev_node = None
        elif current_item.next_node is None:
            self.tail = current_item.prev_node
            self.tail.next_node = None
        else:
            current_item.prev_node.next_node = current_item.next_node
            current_item.next_node.prev_node = current_item.prev_node
        self._length -= 1

    def display(self):
        """Return string representing LinkedList as Python tuple."""
        display_string = u''
        current_node = self.head
        while current_node:
                display_string = '{} {}'.format(current_node.val,
                                                display_string)
                current_node = current_node.next_node
        display_string = display_string.strip().replace(' ', ', ')
        display_string = '({})'.format(display_string)
        return display_string

    def __len__(self):
        """Return the size of a doubly linked list, overwriting len method."""
        return self._length


class Node(object):
    """Set properties and methods of Node class."""

    def __init__(self, val, next_node=None, prev_node=None):
        """Create new Node."""
        self.val = val
        self.next_node = next_node
        self.prev_node = prev_node

@@ -1720,33 +1720,37 @@
 urn current_node
+.val
 %0A
-
 %0A    def shift(s
@@ -2199,16 +2199,20 @@
 ent_node
+.val
 %0A%0A    de
@@ -2930,32 +2930,32 @@
 _item.prev_node%0A
+
         self._le
@@ -2969,527 +2969,8 @@
  1%0A%0A
-    def display(self):%0A        %22%22%22Return string representing LinkedList as Python tuple.%22%22%22%0A        display_string = u''%0A        current_node = self.head%0A        while current_node:%0A                display_string = '%7B%7D %7B%7D'.format(current_node.val,%0A                                                display_string)%0A                current_node = current_node.next_node%0A        display_string = display_string.strip().replace(' ', ', ')%0A        display_string = '(%7B%7D)'.format(display_string)%0A        return display_string%0A%0A
     

Update doubly_linked_list.py