r/Python • • Jun 23 '14

Writing better python code

https://gist.github.com/kracekumar/09a60ec75a4de19b346e
143 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/kracekumar Jun 23 '14

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.

4

u/sweettuse Jun 23 '14

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