diff --git a/py/dictionary_frequency.py b/py/dictionary_frequency.py new file mode 100644 index 000000000..9c732b0d0 --- /dev/null +++ b/py/dictionary_frequency.py @@ -0,0 +1,13 @@ +def word_count(str): + counts = dict() + words = str.split() + + for word in words: + if word in counts: + counts[word] += 1 + else: + counts[word] = 1 + return counts + +sentence = input("enter sentence: ") +print( word_count(sentence))