d02
This commit is contained in:
parent
6f56d563d4
commit
e1be7d9d73
@ -6,7 +6,7 @@ def find_hamlet_lines(file_path):
|
|||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
|
|
||||||
hamlet_lines = []
|
hamlet_lines = []
|
||||||
pattern = re.compile(r'\bHamlet\b')
|
pattern = re.compile(r'Hamlet')
|
||||||
|
|
||||||
for _, line in enumerate(lines, start=1):
|
for _, line in enumerate(lines, start=1):
|
||||||
if re.search(pattern, line):
|
if re.search(pattern, line):
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
Here comes Hamlet
|
Here comesHamlet
|
||||||
ABC
|
ABC
|
||||||
Hamlet Hamlet again
|
Hamlet Hamlet again
|
||||||
|
19
TaskD02/run.py
Normal file
19
TaskD02/run.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
def find_pies_lines(file_path):
|
||||||
|
with open(file_path, 'r') as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
pies_lines = []
|
||||||
|
pattern = re.compile(r'\b[pP][iI][eE][sS]\b')
|
||||||
|
|
||||||
|
for _, line in enumerate(lines, start=1):
|
||||||
|
if re.search(pattern, line):
|
||||||
|
pies_lines.append(line)
|
||||||
|
|
||||||
|
return pies_lines
|
||||||
|
|
||||||
|
path = os.path.join(os.path.dirname(__file__), 'simple.in')
|
||||||
|
lines = find_pies_lines(path)
|
||||||
|
print(lines)
|
Loading…
Reference in New Issue
Block a user