|
发表于 2020-5-15 12:41:32
|
显示全部楼层
- import random
- secret=random.randint(1,100)
- time=3
- guess=0
- print('-----welcome to game world-----')
- print('give a number:')
- while (guess!=secret)and (time>0):
- temp=input('')
- guess=int(temp)
- time=time-1
- if(guess==secret)and (time >= 0):
- print('Wa!congratulations to you')
- else:
- if (guess>secret)and (time >= 0):
- print('sorry,too big')
- if (guess<secret) and (time >= 0):
- print('sorry,too small')
- #这里不用再判断等于0的情况,否则会出现输入三次,判断两次的情况
- print('sorry,there no times, game over')
复制代码 |
|