djfz-2020-s444344/TaskD01/run

33 lines
810 B
Plaintext
Raw Normal View History

2020-12-02 21:30:15 +01:00
#!/usr/bin/python3
import sys
import re
def upperToLower(m):
temp=''
2020-12-02 23:21:09 +01:00
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:
2020-12-02 21:30:15 +01:00
for l in m.group(0):
2020-12-02 23:21:09 +01:00
if re.match(r'[A-ZĄĆĘŁŃÓŚŹŻ]',l):
2020-12-02 21:30:15 +01:00
temp+=l.lower()
2020-12-02 23:21:09 +01:00
elif re.match(r'[a-ząćęłńóśźż]',l):
2020-12-02 21:30:15 +01:00
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'))