input: Write a function to implement a Double Linked List in Python that can traverse in both directions. The function should include methods to append a node at the end, prepend a node at the beginning, and reverse the list. If the list is reversed, the head should point to the last node of the original list.
  assert DoubleLinkedList().reverse().head is None
  assert DoubleLinkedList().append(1).append(2).reverse().head.data == 2
  assert DoubleLinkedList().prepend(1).prepend(2).reverse().head.data == 1
  assert DoubleLinkedList().append(1).append(2).prepend(0).reverse().head.data == 2
  assert DoubleLinkedList().append(1).append(2).append(3).reverse().head.data == 3
output: class Node:
      def __init__(self, data):
          self.data = data
          self.next = None
          self.prev = None
  
  class DoubleLinkedList:
      def __init__(self):
          self.head = None
          self.tail = None
  
      def append(self, data):
          new_node = Node(data)
          if not self.head:
              self.head = new_node
              self.tail = new_node
          else:
              new_node.prev = self.tail
              self.tail.next = new_node
              self.tail = new_node
          return self
  
      def prepend(self, data):
          new_node = Node(data)
          if not self.head:
              self.head = new_node
              self.tail = new_node
          else:
              new_node.next = self.head
              self.head.prev = new_node
              self.head = new_node
          return self
  
      def reverse(self):
          current = self.head
          while current:
              current.next, current.prev = current.prev, current.next
              current = current.prev
          self.head, self.tail = self.tail, self.head
          return self