jfz-2023-s474155/TaskA03/run.py

52 lines
1.3 KiB
Python

def checkDigit(char):
digits=['1','2','3','4','5','6','7','8','9']
for j in range(len(digits)):
if char==digits[j]:
return char
return None
def checkYear(file):
with open(file, "r", encoding="utf-8") as sampleCheck:
line = 0
lineCount = 0
flag =0
for row in sampleCheck:
line += 1
date = ''
for char in row.lower():
if char=='1':
flag = 1
date += char
elif flag==1 and char=='9':
flag=2
date += char
elif flag==2 and char==checkDigit(char):
flag=3
date += char
elif flag==3 and char==checkDigit(char):
flag=4
date += char
elif flag==4 and char==' ':
flag=5
date+=char
elif flag==5 and char=='r':
flag=6
date+=char
elif flag==6 and char=='.':
flag=7
date+=char
if flag==7:
flag =0
date=''
print(line)
file = 'simple.in'
checkYear(file)