coverting list back to string

Dialtone dialtone at despammed.com
Mon Apr 21 15:50:13 EDT 2003


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()


-- 
try: troll.uses(Brain)
except TypeError, data: 
   troll.plonk()
Co-Responsabile Hardware Information & Technology http://hit.edengames.net




More information about the Python-list mailing list