Simple thing about printing

sik0fewl xxdigitalhellxx at hotmail.com
Wed Mar 12 16:46:11 EST 2003


Luke McCarthy wrote:
> It's funny how you use Python for a while and then something very simple
> comes up and stops you.
> How can I print without a newline being automatically inserted at the end?
> 
> Luke McCarthy

print "my",
print "text"

Output:
my text

The trailing comma will stop a newline from being printed. If don't want 
the trailing space either then you need to use sys.stdout.write().

-- 
HTH,
Ryan





More information about the Python-list mailing list