[Tutor] Coding for a Secret Message in a Game

Danny Yoo dyoo at hashcollision.org
Fri Dec 13 20:20:37 CET 2013


Whoops, made a small typo in the program I sent.  Let me rewrite again:

###############################################################
def GetFailureMessage(failure_count):
    """Returns a message given how many times we've seen failure."""
    if failure_count <= 1:
        return "Try again"
    else:
        return "Please try again"

## Let's try it out:
print(GetFailureMessage(0))
print(GetFailureMessage(1))
print(GetFailureMessage(2))
###############################################################

(The mistake was in my "documentation string" at the beginning of the
function.  I put too few quotes at the end.  Sorry about that!)


More information about the Tutor mailing list