Write a Python program to convert a list into a nested dictionary of keys.


Topic: Write a Python program to convert a list into a nested dictionary of keys.

Solution

num_list = [1, 2, 3, 4]
new_dict = current = {}
for name in num_list:
current[name] = {}
current = current[name]
print(new_dict)



List all Python Programs