commit 4d9a26aff59f6d03e6b85dd839c6de7f9a7aa20c Author: zevav Date: Mon Aug 13 22:31:00 2018 -0400 first diff --git a/count.py b/count.py new file mode 100644 index 0000000..4a21f5d --- /dev/null +++ b/count.py @@ -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