jfz-2023-s464983/TaskA01/run.py
2023-10-29 22:02:40 +01:00

20 lines
592 B
Python

def findHamlet(filename):
target = "Hamlet"
target_length = len(target)
with open(filename, 'r', encoding="utf-8") as file:
line_number = 1
for line in file:
for i in range(len(line) - target_length):
match=True
for j in range(target_length):
if line[i+j] != target[j]:
match=False
break
if match:
print(f"Line {line_number}")
break
line_number += 1
findHamlet('TaskA01/simple.in')