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

Time:09-26

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?

CodePudding user response:

Try this solution here https://pypi.org/project/pyspellchecker/

I hope i could help

CodePudding user response:

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