I've seen quite a lot of answers on flattening dictionaries here but couldn't really apply any of them to my case. I have an example of the structure of the dictionary below and the output that I think would be ideal but not necessary. Anything to flatten it in a way that points to the value instead of the key would be great.
(most of the answers I found here were always using the key and that wouldn't be very helpful in this situation)
b = [
{'name': 'Level A',
'children': [
{'name': 'Level B',
'children': [
{'name': 'Level C'},
{'name': 'Level D'},
{'name': 'Level E',
'children': [
{'name': 'Level Z'}
]}
]
},
{'name': 'Level F',
'children': [
{'name': 'Level G'}
]}
]
},
{'name': 'Level M',
'children': [{'name': 'Level N'},
{'name': 'Level Y'}
]
}
]
Wanted output:
l = ['Level A-Level B-Level C',
'Level A-Level B-Level D',
'Level A-Level B-Level E-Level Z',
'Level A-Level F-Level G',
'Level M-Level N',
'Level M-Level Y']
Thank you all in advance!