So, there are a number of interesting "beginners'" issues here.
First num1 or num2 == 3
is evaluated as (num1) or (num2==3)
and then we have to figure out how to convert (num1)
into something that is true or false. It so happens that in python, the number 0 is false, and all other numbers are true.
So what you really want is num1==3 or num2==3
.
You also need to think about the other part of the if
: you want to check whether the character "3" is in the string you made from the number, not whether the number 3 is in the string (which doesn't even really make sense). So '3' in str(num1 + num2)
.
But wait, there's more. Whenever you see the pattern
if something:
return True
else:
return False
you should think deeply about what's happening: something
is turning out to be True
or False
and the routine is then returning True
or False
. Which means you can instead just do
return something