d01
This commit is contained in:
parent
858de1d809
commit
6f56d563d4
19
TaskD01/run.py
Normal file
19
TaskD01/run.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user