As mentioned elsewhere a possible issue with dct.get(key, default) is that, if key in dct but dct[key] is None, you get None not your default:
>>> dct = dict(foo=123, baz=None) >>> dct.get("foo", 0) 123 >>> dct.get("bar", 0) 0 >>> dct.get("baz", 0) >>> # returnswhere'd None,the notvalue 0go? Since Python 3.8, using the "walrus operator" to create an assignment expression, you can handle this like:
>>> value if (value := dct.get("baz")) is not None else 0 0