title: merging two sorted linked lists into one linked list in python
body: <p>here is my code:</p>
  
  <pre><code>def merge_lists(head1, head2):
      if head1 is None and head2 is None:
          return None
      if head1 is None:
          return head2
      if head2 is None:
          return head1
      if head1.value &lt; head2.value:
          temp = head1
      else:
          temp = head2
      while head1 != None and head2 != None:
          if head1.value &lt; head2.value:
              temp.next = head1
              head1 = head1.next
          else:
              temp.next = head2
              head2 = head2.next
      if head1 is None:
          temp.next = head2
      else:
          temp.next = head1
      return temp
      pass
  </code></pre>
  
  <p>the problem here is stucked in the infinite loop.can any one tell me what the problem is </p>
  
  <p>the examples are:</p>
  
  <pre><code> assert [] == merge_lists([],[])
   assert [1,2,3] == merge_lists([1,2,3], [])
   assert [1,2,3] == merge_lists([], [1,2,3])
   assert [1,1,2,2,3,3,4,5] == merge_lists([1,2,3], [1,2,3,4,5])
  </code></pre>