Creating nested dictionaries from a list containing paths
问题 I have a list containing paths. For example: links=['main', 'main/path1', 'main/path1/path2', 'main/path1/path2/path3/path4', 'main/path1/path2/path3/path5', 'main/path1/path2/path3/path4/path6'] I want to create a nested dictionary to store these paths in order. Expected output: Output = {‘main’: {‘path1’: {‘path2’: {‘path3’: {‘path4’: {‘path6’: {} }},‘path5’:{}}}}} I am new to python coding (v 3.+) and I am unable to solve it. It gets confusing after i reach path 3 as there is path 4 (with