#2
古1232020-06-08 15:03
|
对着教材输入的一段代码(猜数字游戏)
在CMD命令窗口执行,
为什么总是显示invalid syntax错误呢
非常感谢
只有本站会员才能查看附件,请 登录
import random
number=random.randint(1,100)
guess=0
while True:
num_input=input('please input a number between 1 and 100')
guess+=1
if not num_input.isdigit():
print('please input a number')
elif int(num_input)<0 or int(num_input)>=100:
print('the number you input must be in 1 and 100')
else:
if number==int(num_input):
print(f'congrats, you got it, you guessed {guess} times')
break
elif number>int(num_input):
print('you input a smaller data')
elif number<int(num_input):
print('you input a bigger data')
else:
print('system has a unpredictable problem, please contact the service staff for dealing')