If it is one-char to one-char translation, you can do even more elegant
def correct(text): corrections = str.maketrans('15', 'IS') # or corrections = str.maketrans({'1':'I', '5':'S'}) return text.translate(corrections) print(correct("1teruje5z t0"))this will not work for one-char to many-char-string translation
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs