First, create a text file and write the wrong spelling of something within it, like I put this:
Python is grat!
Then create a python file, write this content within it, and definitely read the comments I put in the code for clear information:
from textblob import TextBlob # importing the textblob module. (name mentioned in description also.)
file1 = open("1.txt", "r+") # opening the file to judge upon.
# I just named the file as 1.txt, you can name it anything and dont forget to put the real name of the file you created.
a= file1.read() # Reading the file selected to judge upon.
print("The wrong spelling you wrote: ", str(a)) # Telling the wrong spelling you wrote previously.
b = TextBlob(a) # Letting textblob read it because we need to use some of its functions.
print("The correct spelling of that text was: "+str(b.correct())) # The correct spelling.
file1.close() # Clearing the file cache.
# Writing an if statement to detect while the file has something or not.
if a == "" or a == " ":
print("NO content sorry!") #Statement to be printed if the condition is met.
d = open("1.txt", "w") # Opening the file again (for sometime).
d.write(str(b.correct())) # Updating the correct spelling into our text file.
d.close() # Clearing the cache finally.
Wow, the output is here:


