from collections import defaultdict d = defaultdict(int) d['non_existant_key']
d.get("non_existant_key", default)