-1
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

変数の推測が変更されていないのはなぜですか。低が 50 に変更されると予想しているため、newGuess は 75 になります。正しいですか?

4

2 に答える 2