Accessing to a dict on a json in python
<p>I am trying to assign a value of a dict copied in  JSON to a variable in my code. 
This is the dictionary copied on the .json:</p>

<pre><code>"Monetarios": [{"MIFID_NO_CURR_RISK":"B1"},{"MIFID_CURR_RISK":"B2"}],
          "Monetario Dinamico": [{"MIFID_NO_CURR_RISK":"B1"},{"MIFID_CURR_RISK":"B2"}],
          "Renta Fija Corto Plazo": [{"MIFID_NO_CURR_RISK":"B1"},{"MIFID_CURR_RISK":"B2"}],
          "Garantizados de RF": [{"MIFID_NO_CURR_RISK":"B1"},{"MIFID_CURR_RISK":"B2"}],
          "Renta Fija Largo Plazo": [{"MIFID_NO_CURR_RISK":"B1"},{"MIFID_CURR_RISK":"B2"}]
</code></pre>

<p>And i am trying to show on screen for example the B1 of MIFID NO CURR RISK from "Renta Fija Corto Plazo"</p>

<p>I do this and works fine :</p>

<pre><code>carga_dict['Renta Fija Corto Plazo']
Out[56]: [{u'MIFID_NO_CURR_RISK': u'B1'}, {u'MIFID_CURR_RISK': u'B2'}]
</code></pre>

<p>But then I do this and i get an error</p>

<pre><code>carga_dict['Renta Fija Corto Plazo']['MIFID_NO_CURR_RISK']
Traceback (most recent call last):

  File "&lt;ipython-input-57-46b56ce8491a&gt;", line 1, in &lt;module&gt;
    carga_dict['Renta Fija Corto Plazo']['MIFID_NO_CURR_RISK']

TypeError: list indices must be integers, not str
</code></pre>

<p>Thank you all</p>

<pre><code>carga_dict['Renta Fija Corto Plazo'][0]['MIFID_NO_CURR_RISK']
</code></pre>

<p><code>carga_dict['Renta Fija Corto Plazo']</code> is a list of dictionary. so you have to first select the list element and find the appropriate key.</p>

python json dictionary