D1 doesnt work properly

This commit is contained in:
LuminoX 2025-01-29 02:55:49 +01:00
parent 2045b4eb99
commit 3da2b5d83d
2 changed files with 23 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import re
final = []
polish_big = 'AĄBCĆDEĘFGQHIJKLŁMNŃOÓPRSŚTUWXVYZŹŻ'
polish_small = 'aąbcćdeęfgqhijklłmnńoóprsśtuwxvyzźż'
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
@ -15,14 +17,30 @@ with open('polish_wiki_excerpt.in', encoding='utf8') as file:
for words in x:
if words[0] != '':
to_replace = words[0]
new_word = to_replace.swapcase()
new_word = ''
for char in to_replace:
if char in polish_big:
new_word += char.lower()
elif char in polish_small:
new_word += char.upper()
else:
new_word += char
elif words[1] != '':
to_replace = words[1]
new_word = to_replace.swapcase()
new_word = ''
for char in to_replace:
if char in polish_small:
new_word += char.upper()
elif char in polish_big:
new_word += char.lower()
else:
new_word += char
line = line.replace(to_replace, new_word, 1)
print(line)
final.append(line)
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
file.write(line + '\n')
file.write(line + '\n')
### odpowiedź nie do końca pokrywa się z plikiem .exp w wyniku obecności znaków z niemieckiego alfabetu

View File

@ -1,7 +1,7 @@
with open("./TaskD05/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
with open("./TaskD01/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
lines1 = f.readlines()
with open("./TaskD05/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
with open("./TaskD01/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
lines2 = f.readlines()
i = 1