From 86bf5777659c2773344a8abb4935077330ca4281 Mon Sep 17 00:00:00 2001 From: Srinath R <94346083+srinath2003@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:32:56 +0530 Subject: [PATCH 1/2] Add files via upload --- strings/Is_English_word.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 strings/Is_English_word.py diff --git a/strings/Is_English_word.py b/strings/Is_English_word.py new file mode 100644 index 000000000000..9d431f878219 --- /dev/null +++ b/strings/Is_English_word.py @@ -0,0 +1,19 @@ +import nltk +from nltk.corpus import words + +# Download the words corpus +# Get the set of English words once +english_words = set(words.words()) + +def is_english_word(word): + return word.lower() in english_words + +while True: + # Input + input_word = input("Enter a word (or type 'exit' to quit): ") + if input_word.lower() == 'exit': + break + if is_english_word(input_word): + print(f"{input_word} is an English word.") + else: + print(f"{input_word} is not an English word.") From 64f391646f8aac4f91e82924a679402a89fb3f69 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:13:39 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/Is_English_word.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/strings/Is_English_word.py b/strings/Is_English_word.py index 9d431f878219..0d116c00b4f3 100644 --- a/strings/Is_English_word.py +++ b/strings/Is_English_word.py @@ -5,13 +5,15 @@ # Get the set of English words once english_words = set(words.words()) + def is_english_word(word): return word.lower() in english_words + while True: - # Input + # Input input_word = input("Enter a word (or type 'exit' to quit): ") - if input_word.lower() == 'exit': + if input_word.lower() == "exit": break if is_english_word(input_word): print(f"{input_word} is an English word.")