Python大法之猜年龄小游戏

# Allan Haven

#定义年龄变量
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:#次数达到3次用户做选择
        countine_confirm= input("do you want to keep guseeing...?")
        if countine_confirm != "n":
            count = 0
posted @ 2018-07-17 16:03  叫我沙悟净  阅读(152)  评论(0编辑  收藏  举报