On 17/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Okay so i have a list of lists just as you describe below...I hate to make > myself look really stupid...but I don't see how this converts to a tree > structure...I was looking at this earlier and I guess what's confusing me > are the duplicates...do I need to convert the list below into a data > structure of tuples? Can this be plugged straight into a tree control?
Ahh, you will have to write a function. Once you have the data as a list of tuples, all the information is there, but there is a lot of redundancy. You may find it easier to represent your tree as nested dictionaries; the disadvantage of dictionaries is that they are unordered, but this may not matter to you. Here's something for you to try: forget about states for a moment, just make yourself a list of continents and countries: country_tuples = [('north america', 'united states'), ('north america', 'canada'), ('asia', 'japan'), ('asia', 'china'), ('africa', 'zimbabwe')] # etc See if you can convert that to a dictionary like this: world_dict = { 'north america':['united states', 'canada'], 'asia':['japan', 'china'], 'africa':['zimbabwe'] } Your function should start like this: def tupes_to_dict(country_tuples): world_dict = {} for continent, country in country_tuples: # etc return world_dict If you can do that, have a go at applying the same idea to the full data structure. -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor