'''
- A linked list is similar to an array, it holds values. However, links in a linked list do not have indexes.
- This is an example of a double ended, doubly linked list.
- Each link references the next link and the previous one.
'''
from __future__ import print_function


class LinkedList:
    def __init__(self):
        self.head = None
        self.tail = None
        
    def insertHead(self, x):
        newLink = Link(x) #Create a new link with a value attached to it
        if(self.isEmpty() == True): #Set the first element added to be the tail
            self.tail = newLink
        else:
            self.head.previous = newLink # newLink <-- currenthead(head)
        newLink.next = self.head # newLink <--> currenthead(head)
        self.head = newLink # newLink(head) <--> oldhead
    
    def deleteHead(self):
        temp = self.head
        self.head = self.head.next # oldHead <--> 2ndElement(head) 
        self.head.previous = None # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed
        if(self.head is None):
            self.tail = None
        return temp
    
    def insertTail(self, x):
        newLink = Link(x)
        newLink.next = None # currentTail(tail)    newLink -->
        self.tail.next = newLink # currentTail(tail) --> newLink -->
        newLink.previous = self.tail #currentTail(tail) <--> newLink -->
        self.tail = newLink # oldTail <--> newLink(tail) -->
    
    def deleteTail(self):
        temp = self.tail
        self.tail = self.tail.previous # 2ndLast(tail) <--> oldTail --> None
        self.tail.next = None # 2ndlast(tail) --> None
        return temp
    
    def delete(self, x):
        current = self.head
        
        while(current.value != x): # Find the position to delete
            current = current.next
            
        if(current == self.head):
            self.deleteHead()
            
        elif(current == self.tail):
            self.deleteTail()
            
        else: #Before: 1 <--> 2(current) <--> 3
            current.previous.next = current.next # 1 --> 3
            current.next.previous = current.previous # 1 <--> 3
    
    def isEmpty(self): #Will return True if the list is empty
        return(self.head is None)
        
    def display(self): #Prints contents of the list
        current = self.head
        while(current != None):
            current.displayLink()
            current = current.next  
        print()

class Link:
    next = None #This points to the link in front of the new link
    previous = None #This points to the link behind the new link
    def __init__(self, x):
        self.value = x
    def displayLink(self):
        print("{}".format(self.value), end=" ")

@@ -226,16 +226,300 @@
 us one.%0A
+- A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.%0A - Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficent
 '''%0Afrom
@@ -571,16 +571,63 @@
 kedList:
+           #making main class named linked list
 %0A    def
@@ -756,16 +756,43 @@
  Link(x)
+                           
  #Create
@@ -866,16 +866,33 @@
 = True):
+                 
  #Set th
@@ -1007,32 +1007,44 @@
 vious = newLink 
+            
 # newLink %3C-- cu
@@ -1092,16 +1092,36 @@
 lf.head 
+                    
 # newLin
@@ -1173,16 +1173,41 @@
 newLink 
+                         
 # newLin
@@ -1318,16 +1318,34 @@
 ad.next 
+                  
 # oldHea
@@ -1403,16 +1403,35 @@
  = None 
+                   
 # oldHea
@@ -1559,32 +1559,78 @@
 self.tail = None
+                         #if empty linked list
 %0A        return 
@@ -1722,16 +1722,40 @@
  = None 
+                        
 # curren
@@ -1814,16 +1814,35 @@
 newLink 
+                   
 # curren
@@ -1906,16 +1906,31 @@
 lf.tail 
+               
 #current
@@ -1985,16 +1985,40 @@
 newLink 
+                        
 # oldTai
@@ -2137,16 +2137,29 @@
 revious 
+             
 # 2ndLas
@@ -2218,16 +2218,38 @@
  = None 
+                      
 # 2ndlas
@@ -2386,16 +2386,33 @@
 e != x):
+                 
  # Find 
@@ -2836,16 +2836,46 @@
 y(self):
+                              
  #Will r
@@ -2971,16 +2971,47 @@
 y(self):
+                               
  #Prints
@@ -3200,32 +3200,70 @@
     next = None 
+                                      
 #This points to 
@@ -3316,16 +3316,50 @@
  = None 
+                                  
 #This po

Update doubly_linked_list.py (#545)