私は二分法を使用して数値を探しています。私のコードの最初の部分は次のとおりです。エラーの結果は、/またはPythonで混ぜ合わせることによって導かれます
print("Please think of a number between 0 and 100!")
low = 0
high = 100
guess = int(0.5*(low + high))
print("Is your secret number", guess,"?")
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.")
while ans != 'h' or ans != 'l' or ans != 'c':
print("Sorry, I did not understand your input.")
print("Is your secret number", guess,"?")
print(ans)
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.")
ループが戻って続けている間、私は、その後、関係なく、私がキーボードに入れ、何のコードを実行しない場合:「申し訳ありませんが、私はあなたの入力を理解していませんでした」それから私に再度入力を求めてください。
誰でも私にこれがなぜ起こるのか教えていただけますか?
ありがとうございました!
whileループでは 'および'の代わりに 'と'を使用する必要があります – SkrewEverything