Join "colums" of list of lists into "rows" of list of lists
<p>Suppose I have several lists of length n:</p>

<pre><code>a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8, 9]
d = [-1, -2, -3]
</code></pre>

<p>I put those lists into a list:</p>

<pre><code>x = [a, b, c]
</code></pre>

<p>Now I'd like to end up with the following list:</p>

<pre><code>y = [[1, 4, 7, -1], [2, 5, 8, -2], [3, 6, 9, -3]]
</code></pre>

<p>What is a quick and pythonic way to do so? (To get from <code>x</code> to <code>y</code>.)</p>

<p>The entries could be anything, I use numbers just because they visualize good.</p>

<p>There is a very simple and pythonic way to "reverse-zip" a list in this way. Simple use the <code>zip</code> function and the unpacking operator <code>*</code>:</p>

<pre><code>&gt;&gt;&gt; y = zip(*x)
&gt;&gt;&gt; list(y)
[(1, 4, 7, -1), (2, 5, 8, -2), (3, 6, 9, -3)]
</code></pre>

<p>For more information about what is going on, see <a href="http://stackoverflow.com/questions/13635032/what-is-the-inverse-function-of-zip-in-python">What is the inverse function of zip in python?</a></p>

<p>If it is important that it be a list of lists, instead of a list of tuples, you can do the following:</p>

<pre><code>&gt;&gt;&gt; [list(i) for i in zip(*x)]
[[1, 4, 7, -1], [2, 5, 8, -2], [3, 6, 9, -3]]
</code></pre>

python