将2位数表达的年份,转换为用4位数表达:
print("将列表中的2位数年份转换为4位数年份")
lst=[88,89,90,00,99]
print(lst)
for index in range(len(lst)):
if len(str(lst[index]))==2:
lst[index] = 1900+int(lst[index])
elif len(str(lst[index]))==1:
lst[index] = 2000+int(lst[index])
print(lst)
lst = [88,89,90,00,99]
for index,value in enumerate(lst):
if len(str(value))==2:
lst[index]= 1900 + int(value)
else:
lst[index] = 2000 + int(value)
print(lst)