On 16 February 2010 21:32, Shurui Liu (Aaron Liu) <shuru...@gmail.com> wrote: > Here is a program I wrote, I don't know why I cannot exit when I tried 10 > times? Hope somebody can help me. Thank you! > > while (guess != the_number): > if (guess > the_number): > print ("Lower...") > print ("You were wrong, try again", tries, "times left.\n") > else: > print ("Higher...") > print ("You were wrong, try again", tries, "times left.\n") > > guess = int(raw_input("Take a guess: ")) > tries -= 1
This will loop untill guess == the_number with no other way out. Meaning unless the number is guessed it will end up in an infinite loop. You will have to figure out how to *break* out ot the while loop when tries == 0. Greets Sander _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor