python學習筆記之004.py

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/zhendeaini18/article/details/77074935
#!/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'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章