I am a newbie (please correct me if I am wrong), but I happen to think that it would be best to suggest that your input be in the same case as that of your variables. In other words, it appears that you are suggesting the user make an input choice of H, L, or C while the program appears to want to handle the variables h, l, or c.
Clearly my statements do not directly relate to math, but I do not see how your program would be able to handle the input of H, L, or C. On Fri, Aug 15, 2014 at 12:49 PM, Derek Jenkins <derektjenk...@gmail.com> wrote: > I am a newbie (please correct me if I am wrong), but I happen to think > that it would be best to suggest that your input be in the same case > as that of your variables. In other words, it appears that you are > suggesting the user make an input choice of H, L, or C while the > program appears to want to handle the variables h, l, or c. > > Clearly my statements do not directly relate to math, but I do not see > how your program would be able to handle the input of H, L, or C. > > On Fri, Aug 15, 2014 at 3:37 AM, Sibylle Koczian <nulla.epist...@web.de> > wrote: >> 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 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor