Reputation: 11
import enchant
def countWPP(prompt):
#Prompt would be something like "er" or "ua"
d = enchant.Dict("en_US")
count = 0
for word in d:
if d.check(prompt) and prompt in word:
count += 1
return count
D is currently an object, and I'm unsure how to iterate through its dictionary. I've checked the docs, and haven't found anything helpful for this problem. The ideal output for this would be countWPP("er") = 13540 or countWPP("mt") = 1.
When trying to use the function, I got the error "'Dict' object is not iterable" indicating I need to somehow extract a list/dictionary out of the enchant dictionary, but I have no idea how.
Upvotes: 1
Views: 284