From 4575b61608973d08d0e3bd82d8e20cfde9bbe610 Mon Sep 17 00:00:00 2001 From: Milad Khoshdel Date: Sat, 5 Sep 2026 09:25:03 +0330 Subject: [PATCH] fix: correct word_occurrence type hint and typo --- strings/word_occurrence.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strings/word_occurrence.py b/strings/word_occurrence.py index 5a18ebf771e4..c6f4aef81144 100644 --- a/strings/word_occurrence.py +++ b/strings/word_occurrence.py @@ -3,12 +3,12 @@ from collections import defaultdict -def word_occurrence(sentence: str) -> dict: +def word_occurrence(sentence: str) -> defaultdict[str, int]: """ >>> from collections import Counter >>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0" - >>> occurence_dict = word_occurrence(SENTENCE) - >>> all(occurence_dict[word] == count for word, count + >>> occurrence_dict = word_occurrence(SENTENCE) + >>> all(occurrence_dict[word] == count for word, count ... in Counter(SENTENCE.split()).items()) True >>> dict(word_occurrence("Two spaces"))