title: How to loop through JSON data using python?
body: <p>I'm trying to for loop through a json data and only look at &quot;deadline_time&quot; key. But I don't seem to know how to do that!</p>
  <p>Here's my code:</p>
  <pre><code>import json
  from urllib.request import urlopen
  
  with urlopen(&quot;https://fantasy.premierleague.com/api/bootstrap-static/&quot;) as response:
      source = response.read()
  
  data = json.loads(source)
  
  print(json.dumps(data, indent=2))
  
  for item in data['events']['deadline_time']:
      print(item)
  </code></pre>
  <p>Here's what the API looks like:</p>
  <pre><code>    {
        &quot;events&quot;: [
          {
            &quot;id&quot;: 1,
            &quot;name&quot;: &quot;Gameweek 1&quot;,
    ------&gt; &quot;deadline_time&quot;: &quot;2021-08-13T17:30:00Z&quot;,
            &quot;average_entry_score&quot;: 69,
            &quot;finished&quot;: true,
            &quot;data_checked&quot;: true,
            &quot;highest_scoring_entry&quot;: 5059647,
            &quot;deadline_time_epoch&quot;: 1628875800,
            &quot;deadline_time_game_offset&quot;: 0,
            &quot;highest_score&quot;: 150,
            &quot;is_previous&quot;: true,
            &quot;is_current&quot;: false,
            &quot;is_next&quot;: false,
            ...
  </code></pre>
  <p>But I end up getting this error:</p>
  <pre><code>  File &quot;API2.py&quot;, line 11, in &lt;module&gt;
      for item in data['events']['deadline_time']:
  TypeError: list indices must be integers or slices, not str
  </code></pre>