jfz-2023-s464983/TaskA03/run.py

18 lines
755 B
Python
Raw Normal View History

2023-10-29 22:02:40 +01:00
def findDate(filename):
with open(filename, 'r', encoding="utf-8") as file:
line_number = 1
for line in file:
if len(line) >= 7:
for i in range(len(line) - 6):
if line[i] == '1' and line[i+1] == '9':
char3 = line[i + 2] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
char4 = line[i + 3] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if char3 and char4:
if line[i+4] == ' ' and line[i+5] == 'r' and line[i+6] == '.':
print(f"Line {line_number}")
break
line_number += 1
findDate('TaskA03/simple.in')