This commit is contained in:
Pawel Felcyn 2023-12-11 14:07:25 +01:00
parent 858de1d809
commit 6f56d563d4

19
TaskD01/run.py Normal file
View File

@ -0,0 +1,19 @@
import re
import os
def find_hamlet_lines(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
hamlet_lines = []
pattern = re.compile(r'\bHamlet\b')
for _, line in enumerate(lines, start=1):
if re.search(pattern, line):
hamlet_lines.append(line)
return hamlet_lines
path = os.path.join(os.path.dirname(__file__), 'simple.in')
lines = find_hamlet_lines(path)
print(lines)