This easiest way is to build the dictionary starting from the inside out:
tree_dict = {}
for key in reversed(tree_list):
tree_dict = {key: tree_dict}
More Related Contents:
- I don’t know how to display step 3 for this assignment
- How to make a dict from n’th indices of tuples in list
- Access a particular field in arbitrarily nested JSON data [duplicate]
- Convert [key1,val1,key2,val2] to a dict?
- Remove duplicate dict in list in Python
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- list to dictionary conversion with multiple values per key?
- How to overcome TypeError: unhashable type: ‘list’
- How can I convert a dictionary into a list of tuples?
- List of dicts to/from dict of lists
- Appending a dictionary to a list – I see a pointer like behavior
- merging Python dictionaries
- How can I initialize a dictionary of distinct empty lists in Python?
- List of tuples to dictionary [duplicate]
- [] and {} vs list() and dict(), which is better?
- Converting Dictionary to List? [duplicate]
- How to find the min/max value of a common key in a list of dicts?
- Converting a list of tuples into a dict
- Appending a dictionary to a list in a loop
- One liner: creating a dictionary from list with indices as keys
- Group by multiple keys and summarize/average values of a list of dictionaries
- Get a list of values from a list of dictionaries?
- Remove dictionary from list
- How do I sort this list in Python, if my date is in a String?
- How do I extract all the values of a specific key from a list of dictionaries?
- What are dict_keys, dict_items and dict_values?
- How do I send list of dictionary as Body parameter in FastAPI?
- Python The appended element in the list changes as its original variable changes
- Mapping dictionary value to list
- How to sort a list of dictionaries by a value of the dictionary in Python?