0

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")
Matthias
  • 11,699
  • 5
  • 39
  • 45
Nycelease
  • 23
  • 1
  • 5

2 Answers2

0

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"]
>>>
RoadJDK
  • 13
  • 1
  • 3
0

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

Tom McLean
  • 2,254
  • 1
  • 2
  • 21