Find common values in dictionary that has keys with multiple values
<p>I am new to python and I have a problem. I am trying to find keys with a value; however, the keys have multiple values.</p>

<pre><code>d = {
    'a': ['john', 'doe', 'jane'], 
    'b': ['james', 'danny', 'john'], 
    'C':['john', 'scott', 'jane'],
}
</code></pre>

<p>I want to find the value <code>john</code> in d and get the keys a, b and c or find <code>jane</code> and get keys a and c.</p>

<p>So you have to go through the dictionary items and if the find keyword is in the item list then the corresponding key has to be stored in a list and this list has to be displayed.</p>

<pre><code>d = {'a':['john', 'doe', 'jane'], 'b': ['james', 'danny', 'john'], 'C':['john', 'scott', 'jane'],}
find ='jane'
</code></pre>

<p>So this is how the logic is written in python</p>

<pre><code>print ([m for m in d.keys() if find in d[m]])
</code></pre>

<p>And it will give the following output</p>

<pre><code>['a', 'C']
</code></pre>

python python-2.7 dictionary