1. 程式人生 > >While循環猜年齡

While循環猜年齡

退出 宋體 utf-8 style input put print color ali

# -*- 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

While循環猜年齡