I thought about using
from PyDictionary import PyDictionary
word = input("enter a word: ")
dictionary = PyDictionary(word)
check = dictionary.getMeanings()
print(check)
input("press enter to exit")
I thought about using
from PyDictionary import PyDictionary
word = input("enter a word: ")
dictionary = PyDictionary(word)
check = dictionary.getMeanings()
print(check)
input("press enter to exit")
I saw this post a while ago: How to check if a word is an English word with Python?
>>> import enchant
>>> d = enchant.Dict("en_US")
>>> d.check("Hello")
True
>>> d.check("Helo")
False
>>> d.suggest("Helo")
['He lo', 'He-lo', 'Hello', 'Helot', 'Help', 'Halo', 'Hell', 'Held', 'Helm',
'Hero',
"He'll"]
>>>
if you have to use PyDictionary
you can check the meaning of a word and wrap the return in a bool
function:
from PyDictionary import PyDictonary
dictionary = PyDictionary()
valid_word = bool(dictionary.meaning("hdaoij")) # False
valid_word = bool(dictionary.meaning("hello")) # True
or
valid_word = bool(dictionary.meaning(input("enter a word: ")))
Otherwise, I would use the check
function in enchant
, in @RoadJDK's answer