[Tutor] sorting and writing to data file

Peter Otten __peter__ at web.de
Sun Feb 2 15:18:38 CET 2014


Alan Gauld wrote:

> You need a loop such as
> 
> for item in lab3int:
>    intFile.write( str(item) )

You also need to separate the values, with a space, a newline or whatever. 
So:

for item in lab3int:
    intFile.write(str(item))
    intFile.write("\n")

This can be simplified to

for item in lab3int:
    print(item, file=intFile)



More information about the Tutor mailing list