Mar-07-2020, 08:56 PM
I am struggling with finding a value within a dictionary containing nested dictionaries which in turn can contain nested dictionaries, containing lists etc. The value, to be found, can be anywhere, so within a nested dictionary in a nested dictionary in a list, but also within a list within a nested dictionary or just a list. If the value is found more than once, I also want to know the name of the dictionary to which it belongs.
For example: If the value is found in a list and that list belongs to a nested dictionary, I want to know the name of that nested dictionary.
Unfortunately, I am not able to give you an example. Can you give me some pointers who I could solve this problem?
I have thought about it:
Would flatten the dictionary be an option and look trough the values to see if they match and then return their respective keys? The problem is that I do not know how to flatten complex nested dictionaries....
For example: If the value is found in a list and that list belongs to a nested dictionary, I want to know the name of that nested dictionary.
Unfortunately, I am not able to give you an example. Can you give me some pointers who I could solve this problem?
I have thought about it:
Would flatten the dictionary be an option and look trough the values to see if they match and then return their respective keys? The problem is that I do not know how to flatten complex nested dictionaries....