djfz-2020-s444507/TaskD01/run.py

19 lines
531 B
Python
Raw Normal View History

2020-12-05 20:41:36 +01:00
import sys
2020-12-06 18:07:42 +01:00
import re
2020-12-05 20:41:36 +01:00
2020-12-06 18:07:42 +01:00
def replaceLetter(words):
result = ''
for i in words.group(0):
if re.search(r'[a-ząćęłńóśźż]', i):
result += i.upper()
elif re.search(r'[A-ZĄĆĘŁŃÓŚŹŻ]', i):
result += i.lower()
else:
result += i
return result
2020-12-06 15:18:14 +01:00
2020-12-06 15:34:20 +01:00
for line in sys.stdin:
2020-12-06 18:07:42 +01:00
searchRe = re.sub(r'[a-ząćęłńóśźż]+\w*[A-ZĄĆĘŁŃÓŚŹŻ]+\w*|[A-ZĄĆĘŁŃÓŚŹŻ]+\w*[a-ząćęłńóśźż]+\w*', replaceLetter, line)
print(searchRe, end='')