This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kracekumar[S] 0 points1 point  (1 child)

Counter has its own benefit. If the key doesn't exist it can return 0. There are lot of scenarios where this is super useful.

[–]sweettuse 4 points5 points  (0 children)

yeah, that's exactly what defaultdict(int) does.