I have a dd object:
dd = {'111': {'10': {'cid': '555', 'num': '0'}}, '222': {'10': {'cid': '555', 'num': '2'}}, '333': {'10': {'cid': '555', 'num': '2'}}, '121': {'10': {'cid': '555', 'num': '4'}}}
with similar cid
.
I need to find the max dd object with num
:
desired:
desired: {'121': {'10': {'cid': '555', 'num': '4'}}}
I know how to iterate over a nested dict to find the max key
print(max(int(z['num']) for d in dd.values() for z in d.values())) # 4
^ but this gives the value of num
and not the complete object