title: Counting multiple json inputs python
body: <p>I get an input like this:</p>
  <p><code>input 1:</code></p>
  <pre><code>{
  
  &quot;name&quot;: &quot;Ben&quot;,
  &quot;description&quot;: &quot;Ben&quot;,
  &quot;attributes&quot;: [
      {
      &quot;type&quot;: &quot;Background&quot;,
      &quot;value&quot;: &quot;Default&quot;
      },
      {
      &quot;type&quot;: &quot;Hair-color&quot;,
      &quot;value&quot;: &quot;Brown&quot;
      }
  ]
  }
  
  </code></pre>
  <p><code>input 2</code></p>
  <pre><code>{
  
  &quot;name&quot;: &quot;Ice&quot;,
  &quot;description&quot;: &quot;Ice&quot;,
  &quot;attributes&quot;: [
      {
      &quot;type&quot;: &quot;Background&quot;,
      &quot;value&quot;: &quot;Green&quot;
      },
      {
      &quot;type&quot;: &quot;Hair-color&quot;,
      &quot;value&quot;: &quot;White&quot;
      }
  ]
  }
  
  </code></pre>
  <p><code>input 3</code></p>
  <pre><code>{
  
  &quot;name&quot;: &quot;Itay&quot;,
  &quot;description&quot;: &quot;Itay&quot;,
  &quot;attributes&quot;: [
      {
      &quot;type&quot;: &quot;Background&quot;,
      &quot;value&quot;: &quot;Default&quot;
      },
      {
      &quot;type&quot;: &quot;Hair-color&quot;,
      &quot;value&quot;: &quot;Brown&quot;
      }
  ]
  }
  
  </code></pre>
  <p>What I want to do is count the amount of each type of background and each type of hair-color appearing.
  (These are sample examples and in reality there are more types and different values)</p>
  <p>Let's say in these examples we have 2 objects that have a background as default then I want to have a count of that like so:</p>
  <pre><code>Backround default count=2
  hair-color brown = 2
  background green = 1
  hair-color white = 1
  </code></pre>
  <p>I want the most effective code because there are other aspects to the code, in addition it will run on thousands of queries not just two, so needs to run in good times too :D
  My code so far:</p>
  <pre><code>import requests
  import json
  from collections import Counter
  from collections import defaultdict
  from time import sleep
  
  
  attributes = []
  test_dict = defaultdict(list)
  
  for i in range(min_id, max_id+1):
      api = 'api/v1/test/{}'.format(i)
      response = requests.get(api)
  
      item_dict = json.loads(response.text)
  
      for item in item_dict['attributes']:
          attributes.append(item[&quot;trait_type&quot;]) if item[&quot;trait_type&quot;] not in attributes else attributes
          test_dict[item[&quot;trait_type&quot;]].append(item[&quot;value&quot;])
      sleep(0.02)
  
  for attribute in attributes:
      print(attribute)
      print(Counter(test_dict[attribute]))
  </code></pre>