automata-labs/TaskA02/solution.py

15 lines
464 B
Python
Raw Normal View History

2024-12-06 11:27:25 +01:00
# File path to read
file_path = 'text.txt'
# Open the file and search for lines containing the word "pies"
with open(file_path, 'r') as file:
lines_with_pies = []
for line in file:
# Split the line into words and check for the word "pies" (case-insensitive)
words = line.strip().lower().split()
if 'pies' in words:
lines_with_pies.append(line.strip())
# Display the results
for line in lines_with_pies:
print(line)