jfz-2023-s464983/TaskF01/run.py

15 lines
417 B
Python
Raw Permalink Normal View History

2024-01-20 16:39:21 +01:00
import re
def swap(file_path):
pattern = r'\b(?=\w*[a-ząćęłńóśźż])(?=\w*[A-ZĄĆĘŁŃÓŚŹŻ])\w+\b'
def swap_case(match):
return match.group(0).swapcase()
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
swapped_line = re.sub(pattern, swap_case, line)
print(swapped_line, end='')
file_path = 'TaskF01/simple.in'
swap(file_path)