How can I convert a list into nested `dictionary\'?
list
For example:
l = [1, 2, 3, 4]
I\'d like to convert it to a dictio
For that reverse the list, then start creating the empty dictionary element.
l = [1, 2, 3, 4] d = {} for i in reversed(l): d = {i: d} >>> print(d) {1: {2: {3: {4: {}}}}}