I have a dictionary as follows:
data =` {0: {key1: {key2 : [value1 , value2 ,value3]}}}`
Now I have to remove the duplicate value from the list, which is inside the nested dictionary. Also, the function should be recursive and should pass two arguments, like :
remove_duplicates(dict , 'key2')
def remove_duplicate(dict, keys):
for key, value in duplicate_values_dict.items():
if key in dict_keys:
duplicate_values_dict[key] = set(value)
return duplicate_values_dict
Here, I am unable to pass tuple of key, as in the question.
The function should remove the duplicate value from the specified key and append it in a new dictionary.
How do I solve the problem?