In <af59d0cb-5ca3-42ab-83c3-2be84da80...@googlegroups.com> ryankoc...@gmail.com 
writes:

> I've got it working! I'm really enjoying python :) But now i'd like to make 
> it break out of the while loop when the user guesses more than 5 numbers and 
> fails

The "Congratulations" message is inside the while loop; that's why it
always prints.

To break after five guesses, you could change the while loop to this:

    while (guess != number) and (tries < 5): 

And then after the while loop, put this if statement:

    if (tries < 5):
        print "\nCongratulations! You guessed my number in", tries, "tries"

    else:
        print "Sorry, you lost!"

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to