-3
我正在嘗試編碼猜測猜數字的猜謎遊戲。我遇到了append函數的語法錯誤。這是我的錯誤代碼段。我在list1.append(userGuess)
線得到一個錯誤:未知語法錯誤的原因
list1 = []
while userGuess != randomNumber and userGuess != "q":
if userGuess > randomNumber:
userGuess = (int(raw_input('Your guess is too high! Guess another integer or type "q" to quit\n> '))
list1.append(userGuess)
if userGuess < randomNumber:
userGuess = (int(raw_input('Your guess is too low! Guess another integer or type "q" to quit\n> '))
list1.append(userGuess)
userGuess
是一個整數變量。