Am 13.08.2014 01:25, schrieb Greg Markham:
while answer == "h" or "l" or "c":
     print ("My guess is: ", guess, "\n")
     answer = input("Is it (H)igher? (L)ower? Or am I (C)orrect? ")
     answer = answer.lower()
     if answer == "h":
         guess = round(int(guess + (change/2)))
         change = change/2
         tries += 1
     elif answer == "l":
         guess = round(int(guess - (guess/2)))
         tries += 1
     elif answer == "c":
         print ("/n/nYay!  I win.  Shall we play again?\n\n")
         os.system('cls' if os.name <http://os.name> == 'nt' else 'clear')
     else:
         print ("Invalid response.  Please try again.\n")


Something else is wrong, besides the math: this is an infinite loop, because (answer == "h" or "l" or "c") always evaluates to True.

And with the condition you probably wanted:

while answer == "h" or answer == "l" or answer == "c":

the loop wouldn't even start because you set answer = "" in the beginning.





_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to