Else Problems


I honestly believe some of these exorcises should evaluate the actual "is the code correct".
See in code below, I had to add "#return False" just so it would accept my answer.
Even if this is supposed to be enforcing if/else, why not just tell them please use if/else for the answer, currently it treats the answer as totally wrong. Same as ternary, it still treats it as completely wrong unless I add #return False.

answer = "'Tis but a scratch!"

def black_knight():
    return answer == "'Tis but a scratch!"
    #return False

def french_soldier():
    return answer == "Go away, or I shall taunt you a second time!"
    #return False

def black_knight():
    return True if answer == "'Tis but a scratch!" else False
    #return False
def french_soldier():
    return True if answer == "Go away, or I shall taunt you a second time!" else False
    #return False


the link in [compound statements]
( take notice of the colon-: and the required indentation )


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.