How to extract columns from multiple rows in Python using nested loops?
<p>I have a list with 3 sequences</p>

<pre><code>seq_list = ['ACGT', 'ATTT', 'ACCC']
</code></pre>

<p>I want to extract the columns from the the list and store it in another list using nested loops in python</p>

<p>The final output should be </p>

<pre><code>seq_list = ['AAA', 'CTC', 'GTC','TTC']
</code></pre>

<p>I have written the following code, but it does not yield the desired output.</p>

<pre><code>column = []
for i in range(len(seq_list[0])):   #Length of the row
    for j in range(len(seq_list)):    #Length of the column
        column.append(seq_list[j][i])
         print column
</code></pre>

<p>Alternatively, you can <a href="https://docs.python.org/2/library/functions.html#zip" rel="nofollow">"zip" the sequence</a> and <a href="https://docs.python.org/2/library/stdtypes.html#str.join" rel="nofollow">join</a>:</p>

<pre><code>&gt;&gt;&gt; [''.join(item) for item in zip(*seq_list)]
['AAA', 'CTC', 'GTC', 'TTC']
</code></pre>

python python-2.7 for-loop extract multiple-columns