I'm not sure if I understand exactly what you are asking, but if I understand correctly, you probably want to do something like this: def Newtext (n): outp = open("newfile.txt","w") outp.write(n) outp.flush() # note adding flush here outp.close() output = "" for x in range(1, 11): output += "%s %s %s %s\n"% (repr(x).rjust(2), repr(x*x).rjust(3), repr(x*x*x).rjust(4)) Newtext(output) This *should* collect all of your output into one string, then call your Newtext function with that output. steven On Nov 18, 2007 6:43 AM, Super Pija wrote: > hello, > i didn't get any useful answer to the next question in any > programming/python forum. thanks a lot for any help. > Here's the question: > The next code creates a new file, and i can not find the way to write > *in that new file* the list below (*). How to do it? > > def Newtext (n): > outp =3D open("newfile.txt","w") > a =3D "new file" > outp.write(a) > outp.close() > > (*) > >>> for x in range(1, 11): > ... print repr(x).rjust(2), repr(x*x).rjust(3), > ... # Note trailing comma on previous line > ... print repr(x*x*x).rjust(4) > ... > 1 1 1 > 2 4 8 > 3 9 27 > 4 16 64 > 5 25 125 > 6 36 216 > 7 49 343 > 8 64 512 > 9 81 729 > 10 100 1000 > > > > > ____________________________________________________________________________________ > Be a better pen pal. > Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ > > > Send bugs reports to this list. > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" >