помогите import zipfile
from collections import Counter
_dict = {}
def process_text(tet):
for i in tet:
chek = i.isalpha()
if chek:
counter = Counter(i)
_dict.update(counter)
return _dict
archive_name = "voyna-i-mir.zip"
text_file_name = "voyna-i-mir.txt"
with zipfile.ZipFile(archive_name, "r") as zf:
with zf.open(text_file_name, "r") as file:
text = file.read().decode("utf-8")
letter_count = process_text(text)
sorted_letters = sorted(letter_count.items(), key=lambda x: x[1], reverse=True)
for letter, count in sorted_letters:
print(f"буква: {letter} | частота: {count}")
надо чтобы этот код считал все буквы а не только первую
from collections import Counter
_dict = {}
def process_text(tet):
for i in tet:
chek = i.isalpha()
if chek:
counter = Counter(i)
_dict.update(counter)
return _dict
archive_name = "voyna-i-mir.zip"
text_file_name = "voyna-i-mir.txt"
with zipfile.ZipFile(archive_name, "r") as zf:
with zf.open(text_file_name, "r") as file:
text = file.read().decode("utf-8")
letter_count = process_text(text)
sorted_letters = sorted(letter_count.items(), key=lambda x: x[1], reverse=True)
for letter, count in sorted_letters:
print(f"буква: {letter} | частота: {count}")
надо чтобы этот код считал все буквы а не только первую