continue WIP

This commit is contained in:
Andreas Zweili 2021-11-01 18:25:37 +01:00
parent 94b33542ef
commit 1387d6e4e5
1 changed files with 8 additions and 4 deletions

View File

@ -1,11 +1,15 @@
def count_words(input_sentence):
sentence = input_sentence.lower()
sentence = ' '.join(filter(str.isalnum, sentence))
# for character in blocked_characters:
# sentence = sentence.replace(character, " ")
# blocked_characters = [',', '.', ';', ':']
# sentence = ''.join(item for item in sentence if item.isalnum())
words = sentence.split()
result = {}
for word in words:
result[word] = words.count(word)
mod_string = ""
for elem in word:
if elem.isalnum() or elem == "'":
mod_string += elem
result[mod_string] = words.count(word)
return result