代码改变世界

While循环猜年龄

2018-04-09 16:31  何小六soso  阅读(246)  评论(0编辑  收藏  举报
# -*- coding: utf-8 -*-
# 1ly_age年龄30
# 2、猜对退出
# 3、猜错5次询问:n退出,任意键继续

ly_age=30
count=0
while True:
while count<5:
age=int(input("请输入年龄:"))
if ly_age==age:
print("恭喜回答正确。。。。")
break
elif ly_age>age:
print("小于实际年龄。。。")
elif ly_age<age:
print("大于实际年龄。。。")
count+=1
yon=input("n退出,任意键继续")
if yon!="n":
count=0
else:
break