|

楼主 |
发表于 2021-7-15 11:56:44
|
显示全部楼层
- import random
- answer = random.randint(1,10)
- i = 3
- temp = input('请你猜猜我现在心中想的是那个数字:')
- while i > 1 :
- i = i - 1
- if temp.isdigit() == 0:
- print('输入内容不合法,',end='')
- temp = input('请输入一个整数:')
- else:
- guess = int(temp)
- if guess>0 and guess <= 10:
- if guess == answer and i == 2:
- print('你是我肚子里的蛔虫吗!')
- print('不过答对了也没有奖励哦!')
- break
- elif guess == answer and i != 2:
- print('不错,答对了!')
- break
- elif guess > answer:
- print('大了大了,',end='')
- temp = input('再给你一次机会:')
- else:
- print('小了小了,',end='')
- temp = input('再给你一次机会:')
- else:
- print('输入不合法,',end='')
- temp = input('请输入0-10之间的整数:')
- if temp.isdigit() == 0:
- print('输入内容不合法,不过没机会了!')
- else:
- guess = int(temp)
- if guess == answer and i == 1:
- print('机会把握住了,答对了!')
- elif guess == answer and i != 1:
- None
- else:
- print('很可惜,没机会了!')
- print('game over')
复制代码 |
|