We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74bb0a6 commit 91f879aCopy full SHA for 91f879a
strings/word_occurrence.py
@@ -1,6 +1,7 @@
1
# Created by sarathkaul on 17/11/19
2
# Modified by Arkadip Bhattacharya(@darkmatter18) on 20/04/2020
3
from collections import defaultdict
4
+from typing import DefaultDict
5
6
7
def word_occurence(sentence: str) -> dict:
@@ -14,7 +15,7 @@ def word_occurence(sentence: str) -> dict:
14
15
>>> dict(word_occurence("Two spaces"))
16
{'Two': 1, 'spaces': 1}
17
"""
- occurrence: dict = defaultdict(int)
18
+ occurrence: DefaultDict[str, int] = defaultdict(int)
19
# Creating a dictionary containing count of each word
20
for word in sentence.split():
21
occurrence[word] += 1
0 commit comments