3 ms·
You may also be interested in `dict.setdefault`. It has the same behavior as above but also sets the value for the key if it was previously missing. dict.s
by northisup 5y ago
You may also be interested in `dict.setdefault`. It has the same behavior as above but also sets the value for the key if it was previously missing.
dict.setdefault(val, default_val)
[1] https://docs.python.org/3/library/stdtypes.html#dict.setdefault https://docs.python.org/3/library/stdtypes.html#dict.setdefa...