import re def nip(file_path): pattern = r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$' with open(file_path, 'r', encoding='utf-8') as file: for line in file: if re.match(pattern, line.strip()): print('yes') else: print('no') file_path = 'TaskE03/test.in' nip(file_path)