I have a dict like this:
dict
{ (\'America\', 25, \'m\', \'IT\'): 10000, (\'America\', 22, \'m\', \'IT\'): 8999, (\'Japan\', 24, \'f\', \'I
You can replace your entire try/except with this:
res.setdefault((country, sex, job), {})[age] = cnt
Or you could make res a defaultdict(dict) and then it becomes:
res
defaultdict(dict)
res[country, sex, job][age] = cnt