setdefault
If key is in the dictionary, return its value. If not, insert key with a value of default and return default.
1
dict.setdefault(key, default=None)
key
The key to look for/insert.
default
The default value.
Examples
12
a = {'x': 1}
a.setdefault('y', 2)