This commit is contained in:
Volodymyr Baliasnikov 2026-10-06 14:26:47 +02:00
parent 35101ddfb7
commit 971eeeffc7

View File

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