Mar-08-2020, 07:24 AM
(Mar-07-2020, 09:18 PM)Larz60+ Wrote: At least post the dictionary (or sample of if large) showing the nesting.
access should be quite simple
>>> outerdict = { ... 'value1': 45, ... 'innerdict': { ... 'value2': 75, ... 'value3': 'Peter' ... } ... } >>> print(outerdict['innerdict']['value3']) Peter >>>
I understand, but I do not know the key of the value, so I can't reference to it directly. I only know the value, and need to return the key to know if the value is found at the correct entry. This due to possible duplicates in the dictionary.
dict = {'nestedA': OrderedDict([('Name', 'TestCase'), ('VarA', 'Local'), ('VarB', None), ('VarC', None), ('VarD', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), ('VarE', 'ABCD'), ('VarF', 10.0), ('VarG', False)]), 'nestedB': OrderedDict([('LocA', {'v1': 'ABCD', 'v2': None, 'v3': None, 'v4': [[[0, 1], [1, 1], [2, 2], [0, 4]], [[0, 2], [1, 2], [2, 3], [4, 4]], ['name', 'ABCD']]}), ('LocB', None), ('LocC', None), ('LocD', True), ('LocE', True), ('LocF', False), ('LocG', False)])}The above is an example. I am looking for the value 'ABCD' and need to return 'nestedA'+'VarE', 'nestedB'+'LocA'+'v1' and 'nestedB'+'LocA'+'v4'+'name'. This because it is presented three times.