import enchant
df1 = pd.read_excel (r'C:\Users\teeny\OneDrive - Singapore Institute Of Technology\SIT\1002 programming fundamentals\Data Cleaner project\Data Cleaner project\Cleaned Data.xlsx')
dict ={}
dict = df1
d = enchant.Dict("en_US")
for words in dict:
d.check(words)
Asked
Active
Viewed 245 times
-1

Pranav Hosangadi
- 23,755
- 7
- 44
- 70

Tennyson
- 3
- 4
-
1. Don't name your variables `dict`, `list`, or other builtin types. Doing so shadows the type and can lead to bugs that are hard to diagnose. 2. You want to _remove_ an item from your (badly-named) `dict` dictionary. Did you do a [web search](https://duckduckgo.com/?q=python+remove+item+from+dict) for that? Please take the [tour], read [what's on-topic here](/help/on-topic), [ask], and the [question checklist](//meta.stackoverflow.com/q/260648/843953), [How much research?](//meta.stackoverflow.com/a/261593/843953) and how to provide a [mre]. Welcome to Stack Overflow! – Pranav Hosangadi Oct 12 '21 at 16:30
-
Does this answer your question? [Delete an element from a dictionary](https://stackoverflow.com/questions/5844672/delete-an-element-from-a-dictionary) – Pranav Hosangadi Oct 12 '21 at 16:31
1 Answers
1
It would be good to know what your Excel file looks like.
For now, I assumed that you have a list of words, in my code word_list
. This list contains all words.
Then use an empty list to add all English words. In a loop
, you go through your list word for word and check if it is English. You get back a Boolean. If this boolean is True, add the current word to the list. You could also write:
if d.check(word) == True:
But the code at the bottom is shorter.
import enchant
word_list = ['Hello', 'way', 'Backfisch']
english_word_list = []
d = enchant.Dict("en_US")
for word in word_list:
if d.check(word):
english_word_list.append(word)
print(english_word_list)
Judging by your question I would recommend going through this tutorial again to understand what you are doing: Tutorial

Pranav Hosangadi
- 23,755
- 7
- 44
- 70

Jonas
- 31
- 6
-
This is a good answer, but I'd suggest explaining what you're using enchant for. – Kevin McKenzie Oct 12 '21 at 19:27