We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6e24935 commit 86bf577Copy full SHA for 86bf577
strings/Is_English_word.py
@@ -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