title: Python merging list of lists with varying length
body: <p>I want to write a function that merges a list of lists. The lists can be of varying lengths.</p>
  
  <p><code>selected_cells = [[[1],[2],[3]], [[4],[5],[6]], [[7],[8]]]</code></p>
  
  <p>My expected output would be <code>[[1,4,7], [2,5,8], [3,6]]</code></p>
  
  <p>I've written the following function</p>
  
  <pre><code>def merge(lst1, lst2): 
    print('Merging', lst1, 'and', lst2)
    return [(sub + [lst2[i][-1]]) for i, sub in enumerate(lst1) if i &lt; len(lst2)]
  
  for idx, cell in enumerate(selected_cells):
    if idx &lt; (len(selected_cells)-1):
      print(idx)
      selected_cells[0] = merge(selected_cells[0], selected_cells[idx+1])
      print('Output', selected_cells[0])
  </code></pre>
  
  <p>However this outputs <code>[[1, 4, 7], [2, 5, 8]]</code></p>
  
  <p>I feel like I'm missing something simple here and it's driving me nuts. Any help would be appreciated</p>