File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 4
4
from typing import DefaultDict
5
5
6
6
7
- def word_occurence (sentence : str ) -> dict :
7
+ def word_occurrence (sentence : str ) -> dict :
8
8
"""
9
9
>>> from collections import Counter
10
10
>>> 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)
12
12
>>> all(occurence_dict[word] == count for word, count
13
13
... in Counter(SENTENCE.split()).items())
14
14
True
15
- >>> dict(word_occurence ("Two spaces"))
15
+ >>> dict(word_occurrence ("Two spaces"))
16
16
{'Two': 1, 'spaces': 1}
17
17
"""
18
18
occurrence : DefaultDict [str , int ] = defaultdict (int )
@@ -23,5 +23,5 @@ def word_occurence(sentence: str) -> dict:
23
23
24
24
25
25
if __name__ == "__main__" :
26
- for word , count in word_occurence ("INPUT STRING" ).items ():
26
+ for word , count in word_occurrence ("INPUT STRING" ).items ():
27
27
print (f"{ word } : { count } " )
You can’t perform that action at this time.
0 commit comments