Skip to content

2024

#209: Defaultdict

When we work with dictionaries that contains lists, we need to make sure that the list exists before we can add items. Or when we use a dictionary for counters, we must make sure that we have a value before we can increment it. While this can be done by hand, there is a much more elegant way in Python.