title: Find Element by Dictionary-ID in Python List[Dict]
body: <p>The problem I got, is the following: I got JSON-Data which I already converted to a dictionary. The JSON-Data looks like this:</p>
  
  <pre><code>[{"text": "foo1", "value": 1},
  {"text": "foo2", "value": 2}]
  </code></pre>
  
  <p>So my converted json in Python is
  <code>json = [{'text': 'foo1', 'value': 1}, {'text': 'foo2', 'value': 2}]</code>.</p>
  
  <p>The <em>text</em> in these dictionaries is random data and can be swapped for anything the <em>value</em> on the other hand can be interpreted as a fix and unique ID from 1 to infinity.</p>
  
  <p>Now my question is what would possible be the most efficient way of getting out the <em>text</em>.</p>
  
  <p>Because what I tried was</p>
  
  <pre><code>foo1 = [v['text'] for v in json if json['value'] == 1][0]    # and
  foo2 = {list(v.values())[1]: list(v.values())[0] for v in json}[2]
  </code></pre>
  
  <p>though I have to admit that I am not really happy with these solutions...</p>