I have a nested dictionary in the form
'adipisci': {'foo': {'<UNK>': 2},
'adipisci': {'<UNK>': 2},
'non': {'adipisci': {'<UNK>': 2}}
'est': {'<UNK>': 3},
'tempora': {'<UNK>': 5}}
I need to generate
adipisci foo 2
adipisci adipisci 2
adipisci non adipisci 2
adipisci est 3
adipisci tempora 5
I have the following code but I am not getting expected results
def myprint(d,result):
for k, v in d.items():
if k=='<UNK>':
print(result)
if isinstance(v, dict):
result+=' '+k
myprint(v,result)
else:
print("{0} : {1}".format(k, v))