title: My implementation of merging two sorted lists in linear time - what could be improved?
body: <p>Fromg Google's Python Class:</p>
  
  <pre><code>E. Given two lists sorted in increasing order, create and return a merged
  list of all the elements in sorted order. You may modify the passed in lists.
  Ideally, the solution should work in "linear" time, making a single
  pass of both lists.
  </code></pre>
  
  <p>Here's my solution:</p>
  
  <pre><code>def linear_merge(list1, list2):
    merged_list = []
    i = 0
    j = 0
  
    while True:
      if i == len(list1):
          return merged_list + list2[j:]
      if j == len(list2):
          return merged_list + list1[i:]
  
      if list1[i] &lt;= list2[j]:
          merged_list.append(list1[i])
          i += 1
      else:
          merged_list.append(list2[j])
          j += 1
  </code></pre>
  
  <p>First of all, is it okay to use an infinite loop here? Should I break out of the loop using the break keyword when I'm done merging the list, or are the returns okay here?</p>
  
  <p>I've seen similar questions asked here, and all the solutions look quite similar to mine, i.e. very C-like. Is there no more python-like solution? Or is this because of the nature of the algorithm?</p>