Selecting a random tuple from a dictionary
<p>Say I have this:</p>

<pre><code>d={'a':[(1,2),(3,4)],'b':[(9,2),(5,4)],'c':[(2,2),(7,7)]}
</code></pre>

<p>where d is a dictionary in python. I'd like to get random tuples out of this corresponding to a particular key using the <code>random.choice()</code> method.</p>

<p>This is what I'm doing and it's not working:</p>

<pre><code>random.choice(d['a'].values())
</code></pre>

<p><code>d['a']</code> is already a list, so you don't need to call <code>.values()</code> on it.</p>

<pre><code>import random
d = {
    'a': [(1, 2), (3, 4)],
    'b': [(9, 2), (5, 4)],
    'c': [(2, 2), (7, 7)],
}
print(random.choice(d['a']))
</code></pre>

python dictionary tuples