u4
This commit is contained in:
parent
35101ddfb7
commit
971eeeffc7
@ -0,0 +1,15 @@
|
|||||||
|
def count_words(sentence):
|
||||||
|
sentence = sentence.lower()
|
||||||
|
cleaned = ""
|
||||||
|
for symbol in sentence:
|
||||||
|
if symbol.isalnum() or symbol == "'":
|
||||||
|
cleaned += symbol
|
||||||
|
else:
|
||||||
|
cleaned += " "
|
||||||
|
|
||||||
|
counts = {}
|
||||||
|
for word in cleaned.split():
|
||||||
|
word = word.strip("'")
|
||||||
|
if word:
|
||||||
|
counts[word] = counts.get(word, 0) + 1
|
||||||
|
return counts
|
||||||
Loading…
Reference in New Issue
Block a user