Skip to content

Commit 2b19b7d

Browse files
committed
Improve dict initialization
1 parent 4c00e3e commit 2b19b7d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

source-code/typing/dict_correct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def word_count(text: str) -> dict[str, int]:
8-
counts: dict[str, int] = dict()
8+
counts: dict[str, int] = {}
99
words = re.split(r"\W+", text)
1010
for word in words:
1111
word = word.lower()

source-code/typing/dict_incorrect_01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def word_count(text: str) -> dict[str, int]:
8-
counts: dict[str, int] = dict()
8+
counts: dict[str, int] = {}
99
words = re.split(r"\W+", text)
1010
nr_words = 0
1111
for word in words:

0 commit comments

Comments
 (0)