- 帖子
- 18
- 精华
- 0
- 积分
- 56
- 阅读权限
- 20
- 注册时间
- 2017-8-9
- 最后登录
- 2017-9-1
|
from random import randint
Answer=randint(1,100)
totoal=11
left=0
num=0
time=0
well = False
print 'plese input the number you guess!!!'
while int(num) != Answer:
while time<totoal :
num=int(input());
time+=1
left=totoal-time
if num>Answer:
print 'too big,you have['+str(left)+']times'
elif num<Answer:
print 'too small,you have['+str(left)+']times'
elif num==Answer:
print 'congratulations you get it!'
time = time+(totoal-time)+1
else:
print 'sorry,you have get more then 3 time,can not try again!'
well = True
先生,这里是我在前面看到一位同学,我进行了一些优化,这个同学一开始不能使这段代码彻底结束,我优化以后,只有回答正确的答案才能结束,但是回答10次以后,却无法结束,修改了几次,都没办法。希望先生能给我一些指点 |
|