How would I turn a list like ["one","two","three","four"]
into something like {"one": {"two": {"three":{"four"}}}}
where each item in the list would be a descendant of the other element in the dictionary? I think it could be done in a recursive function, but I'm not sure how.
This is what I tried:
l = ["one","two","three","four"]
d = {}
for v in l[:-1]:
d[v] = {l}
d = d[v]
print(d)
Thanks!