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')