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>

<pre><code>new_seq_list = reduce(
  lambda new_seq_list,item:
    new_seq_list + [''.join([item.pop(0) for item in new_seq_list[0]])]
  , range(max([len(item) for item in seq_list])) ,
  [[list(item) for item in seq_list]]
)[1:]
</code></pre>

<ol>
<li>transform the original list into a list of list-of-characters rather than a list of strings</li>
<li>reduce that list once for each character in the longest string</li>
<li>each reduction, add to the new list a string consisting of the first item removed from each list-of-characters, joined together.</li>
<li>at the end, remove the list of now-empty lists from the beginning of the sequence.</li>
</ol>

python python-2.7 for-loop extract multiple-columns