I have a dictionary and a set as follows.
tmp_dict = {1: {'ABCD': 1, 'EFGH': 2}, 2: {'ABCW': 0, 'DEFG': 0}}
s = set(['W','J'])
What I am trying to do is to check if (or which) element of set s exists in the tmp_dict values and filter the associated key and value. This is what I am doing presently, however, I am trying to see if there is any way to reduce the complexity of my approach as I am dealing with a very large set and dictionary.
for key in tmp_dict.keys():
for elem in s:
if any(elem in k for k in tmp_dict[key].keys()):
print(key, tmp_dict[key], elem)
2 {'ABCW': 0, 'DEFG': 0} W