[Tutor] write list to columns
questions.anon at gmail.com
Thu Apr 12 07:33:05 CEST 2012
Perfect, thank you.
Is there a way I could easily/quickly add headings to each column?
On Thu, Apr 12, 2012 at 1:03 PM, Puneeth Chaganti <punchagan at gmail.com>wrote:
> On Thu, Apr 12, 2012 at 8:01 AM, questions anon
> <questions.anon at gmail.com> wrote:
> > I am trying to simply write a list of values to txt file in one column.
> > I would then like to add another list in a second column.
> > Somehow they only appear as one long row.
> > Any feedback will be greatly appreciated.
> You will need to write each line of the file separately, with the
> formatting you desire for each line.
> The following example may help.
> A = range(5)
> B = range(5, 10)
> records = zip(A, B)
> output_format = '%s %s'
> with open('output.txt', 'w') as f:
> for record in records:
> f.write(output_format %(record))
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor