add
This commit is contained in:
parent
0550849871
commit
cf9a217c0f
0
u4/.ipynb_checkpoints/word_count-checkpoint.py
Normal file
0
u4/.ipynb_checkpoints/word_count-checkpoint.py
Normal file
14
u4/word_count.py
Normal file
14
u4/word_count.py
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user