From cf9a217c0f5762d966e29bf450785ec5ee6ead29 Mon Sep 17 00:00:00 2001 From: om350yz Date: Tue, 6 Oct 2026 14:16:11 +0200 Subject: [PATCH] add --- u4/.ipynb_checkpoints/word_count-checkpoint.py | 0 u4/word_count.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 u4/.ipynb_checkpoints/word_count-checkpoint.py create mode 100644 u4/word_count.py diff --git a/u4/.ipynb_checkpoints/word_count-checkpoint.py b/u4/.ipynb_checkpoints/word_count-checkpoint.py new file mode 100644 index 0000000..e69de29 diff --git a/u4/word_count.py b/u4/word_count.py new file mode 100644 index 0000000..de34021 --- /dev/null +++ b/u4/word_count.py @@ -0,0 +1,14 @@ +import string + +def word_count(text): + words = [] + for word in text.lower().split(): + cleaned_word = word.strip(string.punctuation) + if cleaned_word: + words.append(cleaned_word) + + result = {} + for word in words: + result[word] = result.get(word,0) +1 + + return result \ No newline at end of file