An Alternative to Python Dictionaries

Why you should use defaultdict in Python

Jordan Williams
Better Programming
Published in
4 min readApr 6, 2021

--

Books on a shelf
Photo by Sigmund on Unsplash.

Here’s the situation:

Code

We have a list of numbers and we want to find the number of occurrences of each number in the list.

--

--

Enjoys creating software that make tasks simpler. Always trying to gain new knowledge and expertise.