python学习笔记之004.py

来源:互联网 发布:如何加入淘宝热卖 编辑:程序博客网 时间:2024/06/06 06:34
#!/usr/bin/env python
# coding=utf-8
# Created Time:    2017-08-07 12:39:38
# Modified Time:   2017-08-08 13:10:17


number = 23
running = True


while running:
    guess = int(raw_input('Enter an integer : '))


    if guess == number:
        print 'Congratulations,you guessed it.'
        running = True # this causes the while loop to stop
    elif guess < number:
        print 'No,it is a little higher than that'
        running = True
    else:
        print 'No,it is a little lower than that'
        running = False
else:
    print 'The while loop is over.'
    # Do anything  else you want to do here

print 'Done'