python 课堂笔记-while

#Author:zyl

age_of_oldboy = 56
count = 0
while count < 3:
    guess_age = int(input("guess age:"))
    if guess_age == age_of_oldboy:
        print("yes,you got it")
        break
    elif guess_age > age_of_oldboy :
        print("think  smaller")
    else:
        print("think  bigger!")
    count +=1
    if count ==3:
        countine_confirm = input("do you want  to keep guess")
        if  countine_confirm != 'q':     #可以随便指定一个字母q或者a,如果输入为q的时候,则退出,只有输入不是q的时候,即按任意键时,才继续执行
count =0 #计数器复位,重新计数

 

posted @ 2017-09-18 12:33  leon-zyl  阅读(148)  评论(0编辑  收藏  举报