[Tutor] Guess my number?

Joseph Quigley cpu.crazy at gmail.com
Sun Aug 7 20:17:14 CEST 2005


Hi.

> I want the program to say "You're stupid!" When a player fails to guess in
> 10 tries.
> But, it's not working..

Very simple fix for bug:

>     elif (guess < number):
>         print "Higher...\n"
>     elif (tires > 10):
>         print "You're stupid!"
>     else:
>         print "Error!"
> 
>     guess = int(raw_input("Take a guess: "))
>     tries += 1

first off you tries is misspelled (someone probably already caught 
that). Second you have elif guess > ... and then elif tries > .... 
That's your problem. You need:

if tries > 10:
    print "You're stupid."

instead of elif tries > 10....   elif is used only when refering to the 
original if (in this case guess). So you need a new if statement.

Hope this helps.
Joe





More information about the Tutor mailing list