Example dictionary
{
"01_timelines": {
"00_data-managment": {},
"01_rush-and-spot": {}
},
"02_source": {
"00_from_external": {
"01_fonts": {},
"02_logos": {},
"03_graphics": {},
"04_video": {},
"05_3d": {}
},
"01_imported_projects": {}
}
I've looked at: How to completely traverse a complex dictionary of unknown depth?
and some others but If I run the function on my dictionary it will return empty?? I don't know why.
I'm trying to create a custom function:
def print_dict(myfolders,depth,breadcrumb,olddepth):
depth += 1
for key,value in myfolders.items():
if isinstance(value, dict):
if depth == 0:
olddepth = depth
breadcrumb = []
# print(key)
breadcrumb.append(key)
elif depth != olddepth:
olddepth = depth
# tmp = breadcrumb
# tmp.pop()
# tmp.append(key)
breadcrumb.append(key)
print(breadcrumb,key)
else:
print(breadcrumb,key)
print_dict(value,depth,breadcrumb,olddepth)
But it's not completely working: Output needs to be a list:
['01_timelines', '00_data-managment']
['01_timelines', '01_rush-and-spot']
['02_source', '00_from_external']
['02_source', '00_from_external','01_fonts']
['02_source', '00_from_external','02_logos']
enz