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 <puncha...@gmail.com>wrote: > On Thu, Apr 12, 2012 at 8:01 AM, questions anon > <questions.a...@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)) > f.write('\n') > > > HTH, > Puneeth >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor