runfinally

This commit is contained in:
s444379 2020-12-03 15:57:16 +01:00
parent 2db62476ac
commit c17ac10202
2 changed files with 32 additions and 0 deletions

0
TaskD01/Makefile Normal file
View File

32
TaskD01/run Normal file
View File

@ -0,0 +1,32 @@
#!/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'))