1. 作業(yè): 輸入年齡并且將年齡值轉換成整數(shù),如果輸入錯誤程序不崩潰,讓其重新輸入,直到輸入無誤為止...
while True:
try:
age = int(input("請輸入年齡(整數(shù)):"))
if type(age)==int:
break
except:
continue
while True:
try:
age = int(input("請輸入年齡(整數(shù)):"))
if type(age)==int:
break
except:
continue