|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
secret = 10
guess = input('请输入数字:')
chance = 0
while True:
if guess.isdigit():
print('格式输入对了将进行比对...')
break
else:
guess = input('格式输入不合法,请重新输入:')
while True:
if int(guess) == secret and chance < 3:
print('猜对了')
chance = chance + 1
break
elif int(guess) < secret and chance < 3:
guess=input('猜小了,请重新输入:')
while True:
if guess.isdigit():
print('格式输入对了将进行比对...')
break
else:
guess = input('格式输入不合法,请重新输入:')
chance = chance + 1
elif chance < 3:
guess=input('猜大了,请重新输入:')
while True:
if guess.isdigit():
print('格式输入对了将进行比对...')
break
else:
guess = input('格式输入不合法,请重新输入:')
chance = chance + 1
else:
print('没机会了!!!!')
break
本帖最后由 LuLD 于 2019-6-26 16:59 编辑
- secret = 10
- guess = input('请输入数字:')
- chance = 1
- while chance < 3 :
- if guess.isdigit():
- print('格式输入对了将进行比对...')
- else:
- guess = input('格式输入不合法,请重新输入:')
- continue
- if int(guess) == secret:
- print('猜对了')
- break
- elif int(guess) < secret:
- guess=input('猜小了,请重新输入:')
- else :
- guess=input('猜大了,请重新输入:')
-
- chance = chance + 1
- print('机会用完了')
复制代码
|
|