-4
high = 100
low = 0
print('Please think of a number between 0 and 100!')
while True :
middle = (high + low) // 2
print('Is your secret number ' + str(middle))
ans = input("Enter 'h' to indicate the guess is too high. Enter 'l' to
indicate the guess is too low. Enter 'c' to indicate I guessed
correctly.")
if ans == 'h' :
high = ans
print('Is your secret number' + str(middle))
elif ans == 'l' :
low = ans
print('Is your secret number' + str(middle)
elif ans == 'c' :
break
print('your secret num is' + str(middle))
什麼是錯誤的代碼? 問題是
你想讓人們做你的考試考試嗎? –
您可以以代碼格式發佈錯誤消息。 – zhenguoli