result = {} [result.setdefault(a, {}).update({k:b}) for k, v in m.items() for a, b in v.items()] return result
m –
flip_two_level_mapping()
Notes