I have a list of lists that looks something like this:
data = [['seq1', 'ACTAGACCCTAG'], ['sequence287653', 'ACTAGNACTGGG'], ['s9', 'ACTAGAAACTAG']]
I write the information to a file as follows:
for i in data: for j in i: file.write('\t') file.write(j) file.write('\n')
The result is as follows:
seq1 ACTAGACCCTAG sequence287653 ACTAGNACTGGG s9 ACTAGAAACTAG
Columns are not built neatly due to a change in the length of the first element in each internal list. How can I write the appropriate number of spaces between the first and second elements to make a second column for readability?
source share