猜年龄游戏进阶版
Huang_age = 20
a = 0
while True:
if a <=2:
user_guess = int(input("your guess:\n"))
if user_guess == Huang_age:
print("恭喜你猜对了!")
break
elif user_guess < Huang_age:
print("你猜小了!")
a +=1
else:
print("你猜大了!")
a +=1
elif a == 3:
res = input("还要不要继续:\ny - 继续 q - 退出\n")
if res.lower() == 'y':
a = 0
continue
elif res.lower() == 'q':
break
else:
break