exercism/python/word-count/word_count.py

12 lines
260 B
Python
Raw Normal View History

2021-10-31 13:16:53 +01:00
def count_words(input_sentence):
sentence = input_sentence.lower()
words = sentence.split()
result = {}
for word in words:
counter = 0
if word in words:
counter += 1
result[word] = counter
return result