I have list of keys: list1 =['info', 'websites', 'site'] and a final value = 'check'. I'm trying to build a recursive function that create a nested dictionary as follows:
dict = {'info': {'websites': {'site' : 'check' } } } I tried the following function but my function doesn't get the above output:
def nested_dict(keys_list, value, check_dict, size): if size != 1: print(check_dict) check_dict[keys_list[0]] = nested_dict(keys_list[1:], value, check_dict, size-1) else: print(check_dict) check_dict[keys_list[0]] = value return check_dict I appreciate your help!
ifyou are not returning anything