Skip to content

Commit 91f879a

Browse files
Update word_occurrence.py
1 parent 74bb0a6 commit 91f879a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

strings/word_occurrence.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Created by sarathkaul on 17/11/19
22
# Modified by Arkadip Bhattacharya(@darkmatter18) on 20/04/2020
33
from collections import defaultdict
4+
from typing import DefaultDict
45

56

67
def word_occurence(sentence: str) -> dict:
@@ -14,7 +15,7 @@ def word_occurence(sentence: str) -> dict:
1415
>>> dict(word_occurence("Two spaces"))
1516
{'Two': 1, 'spaces': 1}
1617
"""
17-
occurrence: dict = defaultdict(int)
18+
occurrence: DefaultDict[str, int] = defaultdict(int)
1819
# Creating a dictionary containing count of each word
1920
for word in sentence.split():
2021
occurrence[word] += 1

0 commit comments

Comments
 (0)