-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