This commit is contained in:
Oleksandr Mateshchuk 2026-10-06 14:16:11 +02:00
parent 0550849871
commit cf9a217c0f
2 changed files with 14 additions and 0 deletions

14
u4/word_count.py Normal file
View File

@ -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