33 lines
810 B
Python
33 lines
810 B
Python
#!/usr/bin/python3
|
|
|
|
import sys
|
|
import re
|
|
|
|
def upperToLower(m):
|
|
temp=''
|
|
low=False
|
|
up=False
|
|
|
|
for l in str(m.group(0)):
|
|
if re.match(r'[A-ZĄĆĘŁŃÓŚŹŻ]',l):
|
|
low=True
|
|
if re.match(r'[a-ząćęłńóśźż]',l):
|
|
up=True
|
|
if re.match(r'.*[ÉÊĐ].*',m.group(0)):
|
|
up=False
|
|
if low==True and up==True:
|
|
for l in m.group(0):
|
|
if re.match(r'[A-ZĄĆĘŁŃÓŚŹŻ]',l):
|
|
temp+=l.lower()
|
|
elif re.match(r'[a-ząćęłńóśźż]',l):
|
|
temp+=l.upper()
|
|
else:
|
|
temp+=l
|
|
return str(temp)
|
|
else:
|
|
return str(m.group(0))
|
|
|
|
for line in sys.stdin.readlines():
|
|
temp=re.sub(r'\b\w+\b', upperToLower ,line)
|
|
print(temp.strip('\n'))
|