-2
我不知道爲什麼這個代碼不打印「得到了它」 當我運行它,它只是表明我打印else語句,即使答案是正確的。if語句,並打印在Python
import random as rand
print('Welcome to the guessing game!')
print('type a number between 1 to 9')
running = True
while running:
value = rand.randint(1, 9)
user_guess = input()
if user_guess == value:
print('got it')
else:
print('not at all')
即使嘗試打印值,以確保我的答案是正確的。
嘗試'打印(類型(user_guess),類型(值))' – Kevin
不明白 –
'STR!= int',它永遠不會......你將需要轉換'user_guess ''到的int' [我怎樣才能讀取輸入的整數?] – abccd