There was an error while loading. Please reload this page.
1 parent d2f0490 commit 99b391dCopy full SHA for 99b391d
1 file changed
strings/word_occurrence.py
@@ -3,12 +3,12 @@
3
from collections import defaultdict
4
5
6
-def word_occurrence(sentence: str) -> dict:
+def word_occurrence(sentence: str) -> defaultdict[str, int]:
7
"""
8
>>> from collections import Counter
9
>>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0"
10
- >>> occurence_dict = word_occurrence(SENTENCE)
11
- >>> all(occurence_dict[word] == count for word, count
+ >>> occurrence_dict = word_occurrence(SENTENCE)
+ >>> all(occurrence_dict[word] == count for word, count
12
... in Counter(SENTENCE.split()).items())
13
True
14
>>> dict(word_occurrence("Two spaces"))
0 commit comments