identify a set containing correct values in dictionary of sets
<p>I have a dictionary of sets, and two values to test. I need to identify the set containing both values (there's only one correct set) and return the key of that set. I thought I could get away with a one-liner like that below, but no success this far. </p>

<pre><code>d = {"set1": {"A", "B", "C"}, "set2": {"D", "E", "F"}, "set3":{"A", "D", "C"}}
value1 = "A"
value2 = "B"

def do_values_belong_in_same_set(value1, value2):
    if all(x in v for k, v in d.items() for x in [value1, value2]) is True:
        return True, k
    else:
        return False
</code></pre>

<p>The desired output here would be: True, "set1"</p>

<p>The "v for k, v in d.items()" part doesn't do the trick. Nor does simpler "x in d.values()" What would work? Or will I just need to construct a proper for-loop for this? Thanks for your help!</p>

<pre><code>&gt;&gt;&gt; value1 = "A"
&gt;&gt;&gt; value2 = "B"
&gt;&gt;&gt; d = {"set1": {"A", "B", "C"}, "set2": {"D", "E", "F"}, "set3":{"A", "D", "C"}}
&gt;&gt;&gt; [k for k, v in d.items() if value1 in v and value2 in v]
['set1']
</code></pre>

python python-3.x