JFZ-1/TaskA01/task01.py
2024-11-18 23:31:52 +01:00

13 lines
409 B
Python

def find_hamlet(file_path):
result = ""
try:
with open(file_path, 'r', encoding='utf-8') as file:
for line_num, line in enumerate(file, start=1):
if "Hamlet" in line:
result += line
except Exception as e:
print(f"An error occurred: {e}")
print(result)
find_hamlet("TaskA01\\simple.in")
find_hamlet("TaskA01\\shakespeare.in")