[Tutor] if statement problems(noob question)

Dave Angel davea at davea.name
Mon Apr 8 12:49:22 CEST 2013


On 04/08/2013 06:37 AM, Woody 544 wrote:
> Max,
>
> You've made the arguments a string (so never a number) in:
>
> print "The answer is: " + str(x+y)
>
> MJ

That has nothing to do with the issue.  The str() function call is 
unnecessary, but harmless.  If the two values x and y are ints or 
floats, they will get added in the obvious way long before being 
converted to str().

If they are already strings, they'll be concatenated long before str() 
does a null conversion on the resultant string.

The problem, as I stated in my own response, is that the if statement 
does nothing useful for checking of types.


-- 
DaveA


More information about the Tutor mailing list