File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 44from typing import DefaultDict
55
66
7- def word_occurence (sentence : str ) -> dict :
7+ def word_occurrence (sentence : str ) -> dict :
88 """
99 >>> from collections import Counter
1010 >>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0"
11- >>> occurence_dict = word_occurence (SENTENCE)
11+ >>> occurence_dict = word_occurrence (SENTENCE)
1212 >>> all(occurence_dict[word] == count for word, count
1313 ... in Counter(SENTENCE.split()).items())
1414 True
15- >>> dict(word_occurence ("Two spaces"))
15+ >>> dict(word_occurrence ("Two spaces"))
1616 {'Two': 1, 'spaces': 1}
1717 """
1818 occurrence : DefaultDict [str , int ] = defaultdict (int )
@@ -23,5 +23,5 @@ def word_occurence(sentence: str) -> dict:
2323
2424
2525if __name__ == "__main__" :
26- for word , count in word_occurence ("INPUT STRING" ).items ():
26+ for word , count in word_occurrence ("INPUT STRING" ).items ():
2727 print (f"{ word } : { count } " )
You can’t perform that action at this time.
0 commit comments