猜年龄:
在程序里设定好你的年龄,然后启动程序让用户猜测,用户输入后,根据他的输入提示用户输入的是否正确,如果错误,提示是猜大了还是小了。3次机会,猜错退出。
age = 60
for i in range(3):
guess = int(input("please input age:"))
if guess == age:
print("Congratulations, you got it !")
break
elif guess > age:
print("think smaller!")
else:
print("think bigger!")
else:
print("too many times.....")