title: Looping through JSON object with a conditional
body: <p>Having a bit of difficulties here with looping through this json object <code>content</code>.
  The json file is as such:</p>
  <pre><code>[{'archived': False,
    'cache_ttl': None,
    'collection': {'archived': False,
     'authority_level': None,
     'color': '#509EE3',
     'description': None,
     'id': 525,
     'location': '/450/',
     'name': 'eaf',
     'namespace': None,
     'personal_owner_id': None,
     'slug': 'eaf'},
    'collection_id': 525,
    'collection_position': None,
    'created_at': '2022-01-06T20:51:17.06376Z',
    'creator_id': 1,
    'database_id': 4,
    }, ... ]
  
  </code></pre>
  <p>And I want to loop through each dict in the list check that the collection is not empty and then for each collection if the location equals <code>'/450/'</code> return append that dict to a list.</p>
  <p>My code is as follows.</p>
  <pre><code>content = json.loads(res.text)
  </code></pre>
  <pre><code>for q in content:
    if q['collection']:
      for col in q['collection']:
        if col['location'] == '/450/':
          data.append(q)
    
  print(data) 
  </code></pre>
  <p>Having played around with it I keep either getting <code>ValueError: too many values to unpack (expected 2)</code> OR  <code> TypeError: string indices must be integers</code>
  Any help with my structure would be much appreciated thanks.</p>
  <p>Disclaimer:
  I had previously written this as a list comprehension and it worked like a charm however that doesnt work anymore as I now need to check if the <code>collection</code> is empty.
  How I wrote it previously:</p>
  <pre><code>content = [ x for x in content if x['collection']['location'] == '/450/']
  </code></pre>