- 论坛徽章:
- 0
|
这个是脚本:
number=23
running=True
while running:
guess=int(input('Enter an integer:'))
if guess == number:
print ('Congratulations, you guessed it.')
runing= False
elif guess < number:
print ('No, it is a little higher than that')
else:
print ('No, it is a little lower than that')
else:
print ('The while loop is over.')
print ('Done')
原题地址在此:http://woodpecker.org.cn/abyteofpython_cn/chinese/ch06s03.html
1,首先我不理解的是那个running=true 和 while running. 怎样就默认了true呢?这个running在这里起到了什么作用呢?
2,其次就是按照教程的介绍输出应该是这样的:
$ python while.py
Enter an integer : 50
No, it is a little lower than that.
Enter an integer : 22
No, it is a little higher than that.
Enter an integer : 23
Congratulations, you guessed it.
The while loop is over.
Done
可是我执行之后最后两行也就是
The while loop is over.
Done
显示不出来。
这个是怎么回事呢?
问题很菜 望高手不吝赐教 |
|