13. Else Problems, I Feel Bad For You


#1

answer = "'Tis but a scratch!"

testbool = False
print testbool

def black_knight():
if answer == "'Tis but a scratch!":
return True
else:
return testbool # Make sure this returns False

print testbool

def french_soldier():
if answer == "Go away...":
return True
else:
return testbool # Make sure this returns False

print testbool

"Oops, try again, Did you add a False after each else?"

The code returns "False" for all three print actions.

If I change "testbool" to "False" in french_soldier() it lets me pass the exercise, but I need to understand why "False" is ok, but "testbool," whose value is "False" is not ok.

In the first function, "testbool" is fine as a "False" return, it only gives me the error in the second function.

Thanks.

(edit: the white-space formatting is lost, don't know how to include it)


#2

It may be that the SCT is looking at the actual code and expects to see the literal primitives, True and False.