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

17 lines
563 B
Python

def find_lines_with_pies(file_path):
result = ""
try:
with open(file_path, 'r', encoding='utf-8') as file:
for line_num, line in enumerate(file, start=1):
words = line.strip().split()
for word in words:
if word.lower() == "pies":
result += line
break
except Exception as e:
print(f"An error occurred: {e}")
print(result)
find_lines_with_pies("TaskA02/simple.in")
find_lines_with_pies("TaskA02/polish_wiki_excerpt.in")