|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
times = 3
secret = random.randint(1,10)
guess = 0
print("不如猜一下小甲鱼现在心里想的是哪个数字:",end=" ")
while (guess!=secret) and (times>0):
temp = input()
while not temp.isdigit():
temp=input("抱歉,你的输入有误,请输入一个整数:")
guess=int(temp)
times=times-1 #用户每输入一次,可用机会-1
if guess == secret:
print("你是怎么猜中的!!!")
print("猜中无奖励!")
else:
if guess > secret:
print("大了,大了··")
else:
print("小了,小了··")
if times > 0:
print("再试一次吧:",end=" ")
else:
print("机会用光咯!")
print("游戏结束")
求好心人帮解释下蓝色部分的意思,特别是“while not temp.isdigit():” 这个isdigit()表示什么 |
|