Answers for "defaultdict initialize keys"

0

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') })
Posted by: Guest on February-13-2020

Python Answers by Framework

Browse Popular Code Answers by Language