Набросал следующий код:
try:
filename = input(“Enter the path to the file: ”)
file = open(filename, “r”)
cont = file.read()
ru = “АаВЕеКМНОоРрСсТуХх”
en = “12BEeKMHOoPpCcTyXx”
total = 0
for c in cont:
if c in ru:
total += 1
ind = ru.index©
nc = en
print(nc)
cont.replace(c, nc)
part = str(round(total/len(cont), 2) * 100) + ‘%’
print(total, len(cont), part)
print(cont)
file.close()
except FileNotFoundError:
print(“The file is not found”)
except ZeroDivisionError:
print(“The file is empty”)
except:
print(“The erroe occured”)
Обнаружилось, что вроде всё работает, кроме метода replace. Что вместо него поставить или как его заставить работать?