import re def pies_reg(file_path): licznik = 0 with open(file_path, 'r', encoding='utf-8') as file: for line in file: licznik += 1 if (re.search("(^|\s)pies($|\s)", line, re.IGNORECASE)): print(f"{licznik}: {line.strip()}") file_path = 'TaskD02\simple.in' pies_reg(file_path)