Skip to content

Commit 86bf577

Browse files
authored
Add files via upload
1 parent 6e24935 commit 86bf577

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

strings/Is_English_word.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import nltk
2+
from nltk.corpus import words
3+
4+
# Download the words corpus
5+
# Get the set of English words once
6+
english_words = set(words.words())
7+
8+
def is_english_word(word):
9+
return word.lower() in english_words
10+
11+
while True:
12+
# Input
13+
input_word = input("Enter a word (or type 'exit' to quit): ")
14+
if input_word.lower() == 'exit':
15+
break
16+
if is_english_word(input_word):
17+
print(f"{input_word} is an English word.")
18+
else:
19+
print(f"{input_word} is not an English word.")

0 commit comments

Comments
 (0)