[Tutor] Help with "Guess the number" script

Danny Yoo dyoo at hashcollision.org
Tue Mar 4 11:10:46 CET 2014


> If not, then you might even try something like:
>
> #########################
> def maybe_print_cold():
>     if guess < (secret - 10) or guess > (secret - 10):
>         print "You are cold!"
>         print
>         print "Please play again!”
> #########################


... Ooops.  You probably need to pass "secret" and "guess" as parameters too.


Here's an amended version of that helper function:

#########################
def maybe_print_cold(secret, guess):
    if guess < (secret - 10) or guess > (secret - 10):
        print "You are cold!"
        print
        print "Please play again!”
#########################


Apologies for the quick-fire email; I didn't want to leave that error hanging.


More information about the Tutor mailing list