defaultdict stores a copy of a dictionary in memory that you can default to if the original gets unintentionally modified.
defaultdict is a container like dictionaries present in the module collections. The functionality of both dictionaries and defaultdict are almost same except for the fact that defaultdict never raises a KeyError. It provides a default value for the key that does not exists.
example
# 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)