JFZ-1/TaskA02/task02.py

17 lines
563 B
Python
Raw Normal View History

2024-11-18 23:31:52 +01:00
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")