# set default values for all keys
d = collections.defaultdict(lambda:1)
# set default value for a key if not exist - will not modify dictionary
value = d.get(key,default_value)
# if key is in the dictionary: return value
# else: insert the default value as well as return it
dict_trie.setdefault(char,{})
# Python program to demonstrate
# defaultdict
from collections import defaultdict
# Function to return a default
# values for keys that is not
# present
def def_value():
return "Not Present"
# Defining the dict
d = defaultdict(def_value)
d["a"] = 1
d["b"] = 2
print(d["a"]) # 1
print(d["b"]) # 2
print(d["c"]) # Not Present