hint = str
low = 0
high = 100
guess = (high + low)/2
answer = int(raw_input("Please think of a number between 0 and 100: "))
while (True):
print "Is your secret number " + str(guess) + "?"
hint = raw_input("H, L, or C: ")
hint = hint.lower()
while (hint != "h" and hint != "l" and hint != "c"):
print "invalid option"
hint = raw_input("H, L, or C: ")
hint = hint.lower()
if (hint == "h"):
low = guess
print "newlow: " + str(low)
print "newGuess: " + str(guess)
elif (hint == "l"):
high = guess
elif (hint == "c"):
print "Correct, the answer was " + str(answer)
break
为什么变量guess没有改变,我预计low会变成50,因此newGuess会变成75,对吗?