python create dictionary with default keys code example
Example 1: defaultdict initialize keys
d = {'a' : 1, 'b' : 2, 'c' : 3}
default_d = defaultdict(list, **d)
# or
d = defaultdict(list,{ k:[] for k in ('a','b','c') })
Example 2: python set python key default
# general syntax; default can be anything
dict.setdefault(key[, default])
# Example:
dict_ = {}
dict_.setdefault('mykey', {})
print(dict_)
# {'mykey': {}}