jfz-2023-s473564/TaskE44/run.py

19 lines
615 B
Python

import re
def analizuj_wiersze(plik):
with open(plik, 'r', encoding='utf-8') as file:
for line in file:
line = line.rstrip()
regex = r'^([A-ZĆŁÓŚŹŻ][a-ząćęłńóśźż]*a)\s([A-ZĆŁÓŚŹŻ][a-ząćęłńóśźż]{1,})$'
match = re.match(regex, line)
if match:
imie, nazwisko = match.groups()
if not re.match(r'^(Kosma|Jarema)$', imie):
print(nazwisko)
else:
print("<NONE>")
else:
print("<NONE>")
analizuj_wiersze("test.in")