How to I print without newline ?

Michael Geary Mike at DeleteThis.Geary.com
Thu May 27 13:05:07 EDT 2004


Ray Cote wrote:
> Putting a comma at the end of each print statement suppresses
> the newline.
>
> print "hello",
> print "world"
>
> Result: helloworld

Actually, that will print "hello world", not "helloworld". Of course, the OP
wanted spaces anyway, so it doesn't matter. To suppress the spaces as well
as the newlines, use sys.stdout.write().

-Mike





More information about the Python-list mailing list