import re def process_line(line): words = re.findall(r'\b(?:[a-ząćęłńóśźż]+\w*|[A-ZĄĆĘŁŃÓŚŹŻ]+\w*)\b', line, flags=re.UNICODE) lowercase_words = [word for word in words if word[0].islower()] uppercase_words = [word for word in words if word[0].isupper()] return f"{len(lowercase_words)} {len(uppercase_words)}" file_path = 'simple.in' with open(file_path, 'r', encoding='utf-8') as file: for line in file: result = process_line(line.strip()) print(result)