djfz-2023-s464986/TaskF01/run.py
2024-01-19 08:23:37 -08:00

18 lines
458 B
Python

import re
import sys
def swap_case(match):
word = match.group()
return ''.join(c.lower() if c.isupper() else c.upper() for c in word)
def transform_text(input_text):
pattern = re.compile(r'\b(?=\w*[a-ząćęłńóśźż])(?=\w*[A-ZĄĆĘŁŃÓŚŹŻ])\w+\b')
transformed_text = pattern.sub(swap_case, input_text)
return transformed_text
for line in sys.stdin:
output_text = transform_text(line)
sys.stdout.write(output_text)