"Robert H" <hrober...@hotmail.com> wrote
name="world"
print("Hello", name,"!")
Hello world !
However, I don't want the space before the exclamation
mark. I want this:
Hello world!
Can anyone out there help me? Thank you.
I see you've already had two answers, a third is
to construct the string before printing it. There
are various ways to do that:
The simplest:
output = "Hello " + name + "!"
An alternative which is more efficient for
larger numbers of substruings is:
output = "".join(["Hello ",name,"!"]) # thats an empty string to
start
The thirs is to use a formatstring, but thats
what Izz did in his print call.
Whichever method you use you then use
print(output)
Lots of options. As Peter said, use the >>> prompt to
experiment to find which works best for you.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor