jfz-2023-s473564/TaskF02/run.py

24 lines
832 B
Python

import re
def analyze_line(line):
result = re.findall(r'([a-ząćęłńóśźż])|([A-ZĄĆĘŁŃÓŚŹŻ])|(\d)|(\s)', line, flags=re.UNICODE)
lower_case_letters = [match[0] for match in result if match[0]]
upper_case_letters = [match[1] for match in result if match[1]]
digits = [match[2] for match in result if match[2]]
special_characters = [match[3] for match in result if match[3]]
result = f"{len(lower_case_letters)} {len(upper_case_letters)} {len(digits)} {len(special_characters)}"
return result
def process_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
line = line.rstrip('\n')
if line:
result = analyze_line(line)
print(result)
file_path = 'simple.in'
process_file(file_path)