[Tutor] Append mode dilemma
rabidpoobear at gmail.com
Wed Dec 9 19:36:40 CET 2009
On Wed, Dec 9, 2009 at 12:11 PM, biboy mendz <bibsmendez at gmail.com> wrote:
> Hello all!
> I'm trying to use the append mode when opening and writing to a file
> but i cant get it to work my way. When run in the present code,
> the user inputs are expectedly 'appended' but not in a newline below the
> line of the existing file.
That's because there is NOT a new line at the end of the file.
It's a file you're appending to, it's up to YOU to create that new line.
And all files should end with newlines anyway (on linux).
So modify your code so that you output a new line at the end of your
> fobj = open(fname, 'a')
> Are you aware of how 'join' works?
at the interactive prompt and see if you can't figure out why you're missing
a newline at the end of your output.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor