Reputation: 30737
out_file.write('Position'+'\t'+'Hydrophobic'+'\n')
for i in position:
out_file.write(str(i)+'\n')
for j in value:
out_file.write('\t'+str(j)+'\n')
so it says
Position Hydrophobic
0 a
1 b
2 c
#... and so on
when it writes to the excel file it puts it puts the j from value at the bottom of the column of the i in position column
How do i put them side by side with '\t' and '\n'?
Upvotes: 1
Views: 1432
Reputation: 85673
for i, j in zip(position, value):
out_file.write(str(i) + '\t' + str(j) + '\n')
or better:
out_file.write('%s\t%s\n' % (str(i), str(j))
or better:
text = ['%s\t%s' % (str(i), str(j) for i, j in zip(position, value)]
text = '\n'.join(text)
out_file.write(text)
Upvotes: 2