forked from miczar1/djfz-24_25
13 lines
409 B
Python
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") |