I have 2 dictionaries that (simplified) look like this:
dict1 = {'X(0,0)': 1, 'X(0,1)': 3, 'X(1,0)':4, 'X(1,1)':2}
dict2 = {'X(0)': 'area1', 'X(1)': 'area2'}
I want to create a third dictionary with the keys of the first one and the values of the second one, if the dict2
key 'X(i)'
is part of the dict1
key 'X(i,j)'
.
So the end result should be like this:
dict3 = {'X(0,0)': 'area1', 'X(0,1)': 'area1', 'X(1,0)':'area2', 'X(1,1)':'area2'}
I have tried following what was suggested here but it is not exactly what I want and cannot make it work.