#!/usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Sandu"
my_age = 27
count = 0
while count < 3:
guess_age = int(input("请输入您猜的年龄:"))
count += 1
if guess_age > my_age:
print("年龄猜大了")
if count == 3:
print("已经超过输入次数了")
elif guess_age < my_age:
print("年龄猜小了")
if count == 3:
print("已经超过输入次数了")
else:
print("恭喜你,猜对了!")
break
############改良版本#####################
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Sandu"
my_age = 27
count = 0
while count < 3:
guess_age = int(input("请输入您猜的年龄:"))
if guess_age > my_age:
print("年龄猜大了")
elif guess_age < my_age:
print("年龄猜小了")
else:
print("恭喜你,猜对了!")
break
count += 1
else:
print("已经超过输入次数了")