Search code examples
pythonspell-checking

Python: check whether a word is spelled correctly


I'm looking for a an easy way to check whether a certain string is a correctly-spelled English word. For example, 'looked' would return True while 'hurrr' would return False. I don't need spelling suggestions or any spelling-correcting features. Just a simple function that takes a string and returns a boolean value.


Solution

  • Two possible ways of doing it:

    1. Have your own file which has all the valid words. Load the file into a set and compare each word to see whether it exists in it (word in set)
    2. (The better way) Use PyEnchant, a spell checking library for Python

    PyEnchant is not actively maintained now.