作业2; 输入年龄并且将年龄值转换为整数,如果输入错误程序不崩溃让其重新输入,直到输入无误为止...
def age_in():
while True:
try:
age = int(input('输入年龄:'))
return age
except (IndentationError ,ValueError):
print('年龄输入错误')
print(age_in())
def age_in():
while True:
try:
age = int(input('输入年龄:'))
return age
except (IndentationError ,ValueError):
print('年龄输入错误')
print(age_in())