title: Does anyone have a better solution for 'iteratively' applying zip in Python?
body: <p>Let us assume we have three lists:</p>
  
  <pre><code>foo = [1, 2, 3]
  bar = [4, 5, 6]
  baz = [7, 8, 9]
  </code></pre>
  
  <p>If I do <code>list(zip(foo, bar, baz))</code> I get a list that looks like this (and this is what I actually want as an end result):</p>
  
  <pre><code>[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
  </code></pre>
  
  <p>What I however couldn't get easily get to work was applying <code>zip</code> "iteratively", i.e. applying it to <code>foo</code> and <code>bar</code> and then at a later stage applying <code>zip</code> to <code>baz</code> again. Something like this:</p>
  
  <pre><code>list(zip(list(zip(foo, bar)), baz))
  </code></pre>
  
  <p>gives me the following result:</p>
  
  <pre><code>[((1, 4), 7), ((2, 5), 8), ((3, 6), 9)]
  </code></pre>
  
  <p>and is not quite what I want. When I played around with it I discovered that:</p>
  
  <pre><code> ls = list(zip(*list(zip(foo, bar))))
   ls.append(baz)
   list(zip(*ls))
  </code></pre>
  
  <p>does exactly what I want and gives me:</p>
  
  <pre><code>[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
  </code></pre>
  
  <p>Does anyone know of a better way of doing this? I feel that my solution is overly complicated for what should be quite simple.</p>