I have this list in python titles = [ '13.3. Risk', '13.3.1. Strategy', 'SubStrategy', '13.3.2. Token', 'Material', 'Impact', 'Aling' ] And I would like to create hierarchy resulting in something like this: |_'13.3. Risk' |____'13.3.1. Strategy' | |____'SubStrategy' |____'13.3.2. Token' |____'Material' |____'Impact' |____'Aling' I have tried regexp, and also the library anytree but I am not getting the desired result. I want to give structure to the list. As a tree or something similar. Continue reading...