[Tutor] First program
Alan Gauld
alan.gauld at btinternet.com
Sat Mar 13 15:54:12 CET 2010
"Luke Paireepinart" <rabidpoobear at gmail.com> wrote
>>> print "The area of a " + Choice + "is " str(Width) + " x " +
>>> str(Height) + " equals " + str(Width * Height) + " square
>>> feet"
>> One thing - you don't need all the str() calls in your example, print
>> already calls str() for you. Also comma separators are better than +
>> signs
>>
> print actually doesn't call str if you use concatenation. So the str()
> calls are necessary if you do not use "," but use "+" instead.
Good catch! - you are, of course, right. When you use + print only
sees a big single string with all the str() conversions already
done. I was thinking of the more usual comma separated
arguments to print
Alan G.
More information about the Tutor
mailing list