|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
麻烦诸位了。
我调好了这个代码后
temp = input('猜数字')
m = str(temp)
while m.isdigit() != isinstance(1,int):
print('抱歉,输入不合法')
temp = input('请输入一个整数')
m = str(temp)
else:
print('开始游戏吧')
想把它带入到写的猜数字游戏中(👇),但是输入小数后无法判断。
import random
secret = random.randint(1,10)
temp = input('猜数字,1~10\n')
guess = int(temp)
m = str(temp)
count = 1
while m.isdigit() != isinstance(1,int):
print('输入错误',end='')
temp = input('请重新输入一个整数')
m = str(temp)
else:
while guess != secret and count < 3:
if guess > secret:
print('大啦大啦',end='')
else:
print('小了小了',end='')
temp = input('再试一次吧')
guess = int(temp)
count += 1
if guess == secret and count < 3:
print('恭喜你答对啦')
else:
print('game over!')
我不太清楚具体哪里有问题,请各位大佬给萌新指导一下,感激不尽 |
|