asher - 11 months ago 39

Python Question

Assume,

`range(len(column)) = 4`

column = ['AAA', 'CTC', 'GTC', 'TTC']

for i in range(len(column)):

a = list(column[i])

Outside of this loop I want a variable,say x to be assigned such that it gives the following output.

`['A', 'A', 'A']`

['C', 'T', 'C']

['G', 'T', 'C']

['T', 'T', 'C']

After doing this, here is what I should be able to do:

In the Next, I want to compare within x. Say x[2] to tell me if 'G' is different from 'T' and if 'G' is different from 'C' and if 'T' is different from 'C'

Answer Source

I believe you are in need of a list of lists

Code:

```
column = ['AAA', 'CTC', 'GTC', 'TTC']
x=[]
for i in range(len(column)):
a = list(column[i])
x.append(a)
print x
```

Output:

```
[['A', 'A', 'A'], ['C', 'T', 'C'], ['G', 'T', 'C'], ['T', 'T', 'C']]
```