|
发表于 2020-4-19 22:02:35
|
显示全部楼层
本帖最后由 zltzlt 于 2020-4-19 22:09 编辑
试试这样:
- import random
- times = 3
- secret = random.randint(0, 10)
- print('-----------woaiyucgongzuoshi------------')
- guess = 0
- print('不妨猜一下小甲鱼现在心里想的是哪个数字:', end='')
- while (guess != secret) and (times > 0):
- temp = input()
- print(temp)
- while not temp.isdigit():
- temp = input('抱歉,您的输入有误,请输入一个整数:')
- guess = int(temp)
- times = times - 1
- if guess == secret:
- print("你是小甲鱼肚子里的蛔虫吗")
- else:
- if guess > secret:
- print("brother,it's so big")
- else:
- print('small,small')
- if times > 0:
- print("再试一次吧", end='')
- else:
- print('机会用光了')
- print("游戏结束")
复制代码 |
|