[Tutor] concatenating two variables
Tue, 23 Oct 2001 08:35:29 +0800
>So, if variable1 = good and variable2 = dog a
>print variable1 + variable2
>How do I output good dog with the above print statement?
You want to replace the "+" with a comma. So use (for as many variables as
you want to print):-
print variable1,variable2, ...
There's also other ways, like the following way using string formatting:
print "%s %s"%(variable1,variable2)
In that string at the beginning you can decide pricisely how the output will
appear. It can have just the 1 space, or whatever else you want. I think
this is fairly unecessary if you just want to print two variables though. :)