title: Get values from keys in JSON
body: <p>I got the JSON below:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;categories&quot;: [
      {
        &quot;category_id&quot;: &quot;1960&quot;,
        &quot;category_name&quot;: &quot;England&quot;,
        &quot;competitions&quot;: [
          {
            &quot;competition_id&quot;: &quot;222&quot;,
            &quot;competition_name&quot;: &quot;Premier League&quot;
          },
          {
            &quot;competition_id&quot;: &quot;203&quot;,
            &quot;competition_name&quot;: &quot;League One&quot;
          },
          {
            &quot;competition_id&quot;: &quot;167&quot;,
            &quot;competition_name&quot;: &quot;Championship&quot;
          },
          {
            &quot;competition_id&quot;: &quot;204&quot;,
            &quot;competition_name&quot;: &quot;League Two&quot;
          },
          {
            &quot;competition_id&quot;: &quot;307&quot;,
            &quot;competition_name&quot;: &quot;National League&quot;
          },
          {
            &quot;competition_id&quot;: &quot;693&quot;,
            &quot;competition_name&quot;: &quot;FA Cup&quot;
          }
        ]
      },
      {
        &quot;category_id&quot;: &quot;2007&quot;,
        &quot;category_name&quot;: &quot;Spain&quot;,
        &quot;competitions&quot;: [
          {
            &quot;competition_id&quot;: &quot;14482&quot;,
            &quot;competition_name&quot;: &quot;LaLiga&quot;
          },
          {
            &quot;competition_id&quot;: &quot;14982&quot;,
            &quot;competition_name&quot;: &quot;LaLiga 2&quot;
          },
          {
            &quot;competition_id&quot;: &quot;989&quot;,
            &quot;competition_name&quot;: &quot;Copa del Rey&quot;
          },
          {
            &quot;competition_id&quot;: &quot;38756&quot;,
            &quot;competition_name&quot;: &quot;Primera Division RFEF&quot;
          },
          {
            &quot;competition_id&quot;: &quot;19477&quot;,
            &quot;competition_name&quot;: &quot;Second Division B&quot;
          }
        ]
      }
    ]
  }
  </code></pre>
  <p>How can I loop through the json using python to get the values of <code>competition_id</code>? I have tried using a for loop but it's only giving competition id of premier league. Below is the code I wrote</p>
  <pre class="lang-py prettyprint-override"><code>for key in categories:
      competitions = key['competitions']
      print(competitions)
  for key in competitions:
      competition_id = key['competition_id']
      print(competition_id)
  </code></pre>