There is a nested dictionary whose second level key is in tuples such as:
dic1={'a': {('a', 'b'): ['c','d'],
('a', 'c'): ['d','f','g'],
('c', 'k'): ['f','h'],
('c', 'j'): [],
('h', 'z'): ['w']
}}
I would like to convert the tuple keys at the second level into other level of key so that the nested dictionary looks like as
{
'a':
{
'a':
{
'b': ['c', 'd'],
'c': ['d', 'f', 'g']
},
'c':
{
'k': ['f', 'h'],
'j': []
},
'h':
{
'z': ['w']
}
}
}
I have tried the code below but I cannot get the expected result
dic2 = {k:[i[0] for i in v] for k,v in dic1.items()}
Thanks in advance.