[Tutor] Append mode dilemma

Albert Sweigart asweigart at gmail.com
Wed Dec 9 20:15:34 CET 2009


Your problem is on this line:

fobj.write('\n'.join(all))

This puts a newline in between each line in "all", but not at the end.
The fix is simple:

fobj.write('\n'.join(all) + '\n')

This will make sure that the last line has a newline at the end of it,
so that when you later append data, it will appear on a fresh line.

-Al Sweigart
You should check out my free beginner's Python book, "Invent Your Own
Computer Games with Python"
http://inventwithpython.com


More information about the Tutor mailing list