How can I replace specific character from a string in python?

Viewed 39

First, I tried to replace a couple of 'e' from the string and the string ended up like the following-

string = 'Python is e high-level progremming lenguege'

How can I replace those 'e' with spelling errors leaving other 'e' unchanged?

2 Answers

you could use textblob.

from textblob import TextBlob

text = "Python is e high-level progremming lenguege"   # incorrect spelling
correct_text = TextBlob(text).correct()
print(correct_text)

>>> Python is e high-level programming language

Note: 'e' is not changed as 'a' because it corrects only spelling not letters or grammers.

Related