diff --git a/python/word-count/word_count.py b/python/word-count/word_count.py index af5bf6f..d0bdbdc 100644 --- a/python/word-count/word_count.py +++ b/python/word-count/word_count.py @@ -1,11 +1,11 @@ def count_words(input_sentence): sentence = input_sentence.lower() + sentence = ' '.join(filter(str.isalnum, sentence)) + # for character in blocked_characters: + # sentence = sentence.replace(character, " ") words = sentence.split() result = {} for word in words: - counter = 0 - if word in words: - counter += 1 - result[word] = counter + result[word] = words.count(word) return result