Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python dict setdefault

# 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,{})
 
PREVIOUS NEXT
Tagged: #python #dict #setdefault
ADD COMMENT
Topic
Name
3+7 =