coverting list back to string

scn regnivon at netscape.net
Tue Apr 22 15:41:05 CEST 2003


Thank you for your help.  This worked.  I incorporated your suggestion
of 'remove = remove[1:]' instead of my original code. I'd like to
figure out how to get each string to output line-by-line, instead of
one continuous string. If you have any suggestion, I'd appreciate it.
Thanks again!

Dialtone <dialtone at despammed.com> wrote in message news:<878yu33a16.fsf at vercingetorix.vercingetorix>...
> regnivon at netscape.net (scn) writes:
> 
> > my quest:  i know that output.write(remove) is not correct.  you
> > cannot use the 'write' method on a list.  is there a better way to
> > convert the list to a string after the first element of the list has
> > been removed and then output the strings to a file?  i'm a newbie
> > programmer and need guru help. thank you.
> 
> Sure:
> 
> input = file('c:/python22/programs/linetest.txt', 'r')
> output = file('c:/python22/programs/output.txt', 'w')
> 
> for line in input:
>     remove = line.split()
>     remove = remove[1:]
>     output.write(''.join(remove))
> 
> input.close()
> output.close()




More information about the Python-list mailing list