From 4d9a26aff59f6d03e6b85dd839c6de7f9a7aa20c Mon Sep 17 00:00:00 2001 From: zevav Date: Mon, 13 Aug 2018 22:31:00 -0400 Subject: [PATCH] first --- count.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 count.py 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