[Tutor] Blank line added after reading a line from a file

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 5 Dec 2001 10:58:58 -0800 (PST)


On Wed, 5 Dec 2001, Andrei Kulakov wrote:
> a list of lines, without adding "\n", and yet another solution is to add
> a comma after the print statement, which prevents it from printing a
> newline, like this:
> 
> print line,


Putting in the comma suppresses print from adding a newline of its own,
but doesn't stop printing newlines if the line itself contains them:

###
>>> def test():
...     print "hello\n"
...     print "hello again\n",
...     print "one more time"
... 
>>> test()
hello

hello again
one more time
###