Max and min value in list of dicts where each dict key has a value
<p>All the answers I found to this seem to make you have to <a href="http://stackoverflow.com/questions/5320871/in-list-of-dicts-find-min-value-of-a-common-dict-field">specify which key</a> you want to find the max/min for e.g. <a href="http://stackoverflow.com/questions/19759374/finding-minimum-values-in-a-list-of-dicts">Finding minimum values in a list of dicts</a>.</p>

<p>I have a list of dicts like:</p>

<pre><code> [
{
    1:34,
    2:12,
    3:24
},
{
    1:121,
    2:1211,
    3:1891
},
{
    1:191,
    2:8991,
    3:3232
}
]
</code></pre>

<p>So here it would pull out 12 and 8991.</p>

<p>And I want to find the max and min of all the values in this list of dicts.</p>

<p>How do I do this without having to specify each key separately (e.g. 1,2,3) - in the real version I have 20+.</p>

<p>You can flatten the values, then find the min and max:</p>

<pre><code>from itertools import chain

flattened = list(chain(*(d.values() for d in list_of_dicts)))
print(min(flattened))
print(max(flattened))
</code></pre>

python list dictionary max min