This commit is contained in:
Zofia Bączyk 2020-12-02 21:30:15 +01:00
parent 9f2fe06109
commit 58cd38f0b5
2 changed files with 22 additions and 0 deletions

0
TaskD01/Makefile Normal file
View File

22
TaskD01/run Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
import sys
import re
def upperToLower(m):
temp=''
if re.match(r'^([A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*)|([A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]+[A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*$)',m.group(0)):
for l in m.group(0):
if l.isupper():
temp+=l.lower()
elif l.islower():
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'))