Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion strings/word_occurrence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Created by sarathkaul on 17/11/19
# Modified by Arkadip Bhattacharya(@darkmatter18) on 20/04/2020
from collections import defaultdict


Expand All @@ -13,8 +14,9 @@ def word_occurence(sentence: str) -> dict:
"""
occurrence = defaultdict(int)
# Creating a dictionary containing count of each word
for word in sentence.split(" "):
for word in sentence.split():
occurrence[word] += 1
occurrence.pop('', None)
return occurrence


Expand Down