Another n00b: Removing the space in "print 'text', var"

Alex Martelli aleaxit at yahoo.com
Sun Feb 12 17:22:34 EST 2006


HappyHippy <not at bleedin.likely> wrote:

> More of a minor niggle than anything but how would I remove the 
> aforementioned space?
> 
> eg.
> strName = 'World'
> print 'Hello', strName, ', how are you today?'
> 
> comes out as "Hello World , how are you today?"
> 
> Have googled, and worked my way through the first 7 chapters of Byte of
> Python, but to no avail...

Use string formatting:

print 'Hello %s, how are you today?' % strName


Alex



More information about the Python-list mailing list