Compare commits
2 Commits
0550849871
...
e6403d63c2
| Author | SHA1 | Date | |
|---|---|---|---|
| e6403d63c2 | |||
| cf9a217c0f |
0
u4/.ipynb_checkpoints/word_count-checkpoint.py
Normal file
0
u4/.ipynb_checkpoints/word_count-checkpoint.py
Normal file
15
u4/word_count.py
Normal file
15
u4/word_count.py
Normal file
@ -0,0 +1,15 @@
|
||||
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