title: 'NoneType' object has no attribute 'next'
body: <p>I am trying to implement quicksort in the single linked list with python .In my quicksort_recur() newhead is Node() type with none value but newhead does not update its value in partition()</p>
  
  <pre><code>class Node(object):
  
      def __init__(self, data):
          super(Node, self).__init__()
          self.data = data
          self.next=None
  
  class Linkedlist(object):
  
      def __init__(self):
          self.head = None
  
  
      #Returns the last node of the list 
      def get_tail(self, node):
          while node.next:
              node = node.next
          return node
      #Partitions the list taking the last element as the pivot 
      def  partition(self,head,end,newhead,newend):
          pivot=end
          prev=None
          curr=head
          tail=pivot
  
          # During partition, both the head and end of the list might change
          # which is updated in the newHead and newEnd variables        
          while curr is not pivot:
              if curr.data&lt;pivot.data:
                  # First node that has a value less than the pivot - becomes the new head 
  
                  if newhead is None:
                      newhead=curr
  
                  prev=curr
                  curr=curr.next
              else:
                  #If cur node is greater than pivot
                  #Move cur node to next of tail, and change tail 
  
                  if prev:
                      prev.next=curr.next
                  temp=curr.next
                  curr.next=None
                  tail.next=curr
                  tail=curr
                  curr=temp
          # If the pivot data is the smallest element in the current list, 
          # pivot becomes the head 
          if newhead is None:
              newhead=pivot
  
  
          newend=tail
  
          return pivot
  
      #here the sorting happens exclusive of the end node 
      def quicksort_recur(self,head,end):
          lists=Linkedlist()
          if head is None or head is end:
              return head
  
          newhead=Node(None)
  
          newend=Node(None)
  
          #Partition the list, newHead and newEnd will be updated by the partition function 
  
          pivot=lists.partition(head,end,newhead,newend)
          # If pivot is the smallest element - no need to recur for the left part
  
          if newhead is not  pivot:
              #Set the node before the pivot node as NULL
              temp=newhead
  
              while temp.next is not pivot:
                  temp=temp.next
              temp.next=None
              #Recur for the list before pivot 
              newhead=lists.quicksort_recur(newhead,temp)
              #Change next of last node of the left half to pivot
              temp=lists.get_tail(newhead)
              temp.next=pivot
          #Recur for the list after the pivot element 
          pivot.next=lists.quicksort_recur(pivot.next,newend)
  
          return newhead
      # The main function for quick sort. This is a wrapper over recursive 
      # function quickSortRecur() 
      def quick_sort(self,head):
          lists=Linkedlist()
          tail=lists.get_tail(head)
          head=lists.quicksort_recur(head,tail)
          return
  
  lists=Linkedlist()
  
  lists.head=Node(10)
  l1=Node(11)
  l2=Node(12)
  l3=Node(13)
  
  lists.head.next=l1
  l1.next=l2
  l2.next=l3
  
  lists.quick_sort(lists.head)
  </code></pre>
  
  <blockquote>
    <p>10Traceback (most recent call last):
          File "C:\Users\Didarul Amin\Desktop\ML algo code\practice_linked_list.py", line 160, in </p>
  
  <pre><code>11
  12
  13
  sort
      lists.quick_sort(lists.head)
    File "C:\Users\Didarul Amin\Desktop\ML algo code\practice_linked_list.py", line 130, in quick_sort
      head=lists.quicksort_recur(head,tail)
    File "C:\Users\Didarul Amin\Desktop\ML algo code\practice_linked_list.py", line 116, in quicksort_recur
      temp=temp.next
  AttributeError: 'NoneType' object has no attribute 'next'
  [Finished in 0.1s with exit code 1]
  </code></pre>
  </blockquote>
  
  <p>'''</p>