make a tree based on the key of each element in list.
- by cocobear
>>> s
[{'000000': [['apple', 'pear']]}, {'100000': ['good', 'bad']}, {'200000': ['yeah', 'ogg']}, {'300000': [['foo', 'foo']]}, {'310000': [['#'], ['#']]}, {'320000': ['$', ['1']]}, {'321000': [['abc', 'abc']]}, {'322000': [['#'], ['#']]}, {'400000': [['yeah', 'baby']]}]
>>> for i in s:
... print i
...
{'000000': [['apple', 'pear']]}
{'100000': ['good', 'bad']}
{'200000': ['yeah', 'ogg']}
{'300000': [['foo', 'foo']]}
{'310000': [['#'], ['#']]}
{'320000': ['$', ['1']]}
{'321000': [['abc', 'abc']]}
{'322000': [['#'], ['#']]}
{'400000': [['yeah', 'baby']]}
i want to make a tree based on the key of each element in list.
result in logic will be:
{'000000': [['apple', 'pear']]}
{'100000': ['good', 'bad']}
{'200000': ['yeah', 'ogg']}
{'300000': [['foo', 'foo']]}
{'310000': [['#'], ['#']]}
{'320000': ['$', ['1']]}
{'321000': [['abc', 'abc']]}
{'322000': [['#'], ['#']]}
{'400000': [['yeah', 'baby']]}
perhaps a nested list can implement this or I need a tree type?