python基础入门---while循环(猜年龄小游戏)

猜年龄小游戏:
age = 24
count = 0
while count < 3:
    guess_age = int(input("guess age:"))
    if guess_age == age:
        print("yes ,you got it")
        break
    elif guess_age > age:
        print("think smaller...")
    else:
        print("think bigger!")
    count +=1
    if count == 3:
        countinue_confirm = input("do you want to keep guessing...?\n")

        if countinue_confirm != 'n':
            count = 0

猜你喜欢

转载自www.cnblogs.com/qjhh/p/12316777.html