renamed count

This commit is contained in:
2018-08-13 22:32:14 -04:00
parent 4d9a26aff5
commit d3119db5c5

19
2018-08-13-count.py Normal file
View File

@@ -0,0 +1,19 @@
from collections import defaultdict
from string import ascii_lowercase
def count_words(string):
word_dict = defaultdict(int)
words = string.split(' ')
for word in words:
word = ''.join(char
for char in word.lower()
if char in ascii_lowercase + "'")
word_dict[word] += 1
return word_dict