From 40fc4a37a2d345d277add807238caeb81e55cfc7 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Mon, 1 Nov 2021 19:36:39 +0100 Subject: [PATCH] extend the word-count exercise --- python/word-count/word_count.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/word-count/word_count.py b/python/word-count/word_count.py index 6d198ce..8cbe827 100644 --- a/python/word-count/word_count.py +++ b/python/word-count/word_count.py @@ -1,7 +1,8 @@ def count_words(input_sentence): sentence = input_sentence.lower() - # blocked_characters = [',', '.', ';', ':'] - # sentence = ''.join(item for item in sentence if item.isalnum()) + blocked_characters = [',', '.', ';', ':', '_'] + for character in blocked_characters: + sentence = sentence.replace(character, " ") words = sentence.split() result = {}