title: Flask If Statement - Range for list index
body: <p>customer_data.json (loaded as customer_data)</p>
  <pre><code>{
    &quot;customers&quot;: [
      {
        &quot;username&quot;: &quot;anonymous&quot;,
        &quot;id&quot;: &quot;1234&quot;,
        &quot;password&quot;: &quot;12341234&quot;,
        &quot;email&quot;: &quot;1234@gmail.com&quot;,
        &quot;status&quot;: false,
        &quot;books&quot;: [
          &quot;Things Fall Apart&quot;,
          &quot;Fairy Tales&quot;,
          &quot;Divine Comedy&quot;
        ]
      }
    ]
  }
  </code></pre>
  <p>Example post in new_catalog.json. (loaded as posts)</p>
  <pre><code>{
    &quot;books&quot;: [
      {
        &quot;author&quot;: &quot;Chinua Achebe&quot;,
        &quot;country&quot;: &quot;Nigeria&quot;,
        &quot;language&quot;: &quot;English&quot;,
        &quot;link&quot;: &quot;https://en.wikipedia.org/wiki/Things_Fall_Apart\n&quot;,
        &quot;pages&quot;: 209,
        &quot;title&quot;: &quot;Things Fall Apart&quot;,
        &quot;year&quot;: 1958,
        &quot;hold&quot;: false
      }
  }
  </code></pre>
  <p>Necessary code in Flask_practice.py</p>
  <pre><code>    for customer in customer_data['customers']:
          if len(customer['books']) &gt; 0:
              for book in customer['books']:
                  holds.append(book)
      
      for post in posts['books']:
          if post['title'] == holds[range(len(holds))]:
              matching_posts['books'].append(post)
  </code></pre>
  <p><code>holds[range(len(holds))]</code> doesn't work.</p>
  <p>I am trying to go through each of the books in <code>holds</code> using <code>holds[0], holds[1]</code> etc and test to see if the <code>title</code> is equal to a book title in <code>new_catalog.json</code>.</p>
  <p>I'm still new to Flask, Stack Overflow and coding in general so there may be a really simple solution to this problem.</p>