大家好
小弟在練習一個猜數字的問題
其中一段程式如下
res = 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 (res is 'c')==False:
If res=='h':
請用戶輸入 h 或 l 或 c
然後 用戶輸入的str 會放入res
我的疑問是下面的invalid syntax該如何修正呢 (我不知道問題在哪)
If res=='h':
^
SyntaxError: invalid syntax
此關於如果輸入不為c
我的寫法是 while (res is 'c')==False:
我好奇有其他的寫法嗎?
謝謝