title: Check a key value from a list of dictionaries of lists of dictionaries against separate list
body: <p>Im trying to loop around a list of dictionaries, with each dictionary containing a list of sub-dictionaries. I want to match each of these sub-dictionary keys to a value in my 'mps' list, which currently contains two author_ids that are also present in the sub-dictionary payload.</p>
  <p>The keys in the main dictionary iterate as such: ['data', 'meta', 'data', 'meta', 'title', 'detail', 'type', 'status'].</p>
  <pre><code>def mp_list6(List, mps):
  p = []
  for mp_dict in List:
      a=0
      try:
          for subDict in mp_dict[&quot;data&quot;]:
              if subDict[&quot;author_id&quot;] in mps:
                  a+=1
                  p.append(a)
      except KeyError:
          if subDict[&quot;author_id&quot;] in mps:
              a=1
              p.append(a)
              return p
  </code></pre>
  <p>The output is a list of integers: [1,2,3....94,1,2,3...155,1]
  Ideally it would be 249. Ive also tried a defaultdict to show the values of the author ids but to no success.</p>
  <p>I have posted screenshots of payloads 1,2, and 3 below being the start, middle and end payload screenshots respectively.<a href="https://i.stack.imgur.com/41tf6.png" rel="nofollow noreferrer">payload1</a> <a href="https://i.stack.imgur.com/2bf1o.png" rel="nofollow noreferrer">payload2</a> <a href="https://i.stack.imgur.com/VOCpr.png" rel="nofollow noreferrer">payload3</a></p>