Making a tree out of a 2 column list

Sebastian Bassi sbassi at clubdelarazon.org
Sat Apr 14 10:37:11 EDT 2007


I have a two column list like:

2,131
6,335
7,6
8,9
10,131
131,99
5,10

And I want to store it in a tree-like structure.
So if I request 131, it should return all the child of 131, like 2, 10
and 5 (since 5 is child of 10).
If I request 335, it should return: 6 and 7.
If I request 9, it should return 8.
I guess I could use tuples or dictionaries to do it, but I can't figure out how.

Best,
SB.


-- 
Sebastián Bassi
Diplomado Ciencia y Tecnología.
Club de la razón (www.clubdelarazon.org)



More information about the Python-list mailing list