title: Nested for loop in Python to generate a dict
body: <p>I want to iterate over all items in items and over all bands in bands (in the item object). But only the outer for loop works and just for the first item. Any ideas why?</p>
  <pre class="lang-py prettyprint-override"><code>from satsearch import Search
  from IPython.display import JSON
  import json
  
  # configuration
  url = 'https://earth-search.aws.element84.com/v0' # URL to Sentinel 2 AWS catalog
  collection = 'sentinel-s2-l2a-cogs'
  
  # search parameter
  startDate = '2021-01-01'
  endDate = '2021-02-01'
  location = [ 11.756057739257812,
            57.649809962218995,
            12.10693359375,
            57.751442372568924
         ]
  
  bbox_search = Search(
      bbox=location, 
      datetime=startDate+&quot;/&quot;+endDate, 
      query={'eo:cloud_cover': {'lt': 50}},
      collections=[collection],
      url=url,
      sort={'field': 'eo:cloud_cover', 'direction': 'desc'},
      )
  
  def get_all_files(*bands):
      bbox_search = Search(
          bbox=location, 
          datetime=startDate+&quot;/&quot;+endDate, 
          query={'eo:cloud_cover': {'lt': 50}},
          collections=[collection],
          url=url,
          sort={'field': 'eo:cloud_cover', 'direction': 'desc'},
      )
  
      items = bbox_search.items()
  
      downloads = {}
      data = {}
      
      for i, item in enumerate(items):
          
          data['Product ID']= item.properties[&quot;sentinel:product_id&quot;]
          data['Preview']= item.asset(&quot;thumbnail&quot;)[&quot;href&quot;]
          data['Date']= item.properties[&quot;datetime&quot;]
          
          for idx, band in enumerate(bands):
              data[band] = item.asset(band)[&quot;href&quot;]
          
          downloads[i] = data
                              
      return downloads
  
  display(JSON(get_all_files(&quot;B01&quot;, &quot;B02&quot;, &quot;B03&quot;)))
  </code></pre>
  <p><strong>Result:</strong>
  The result is, that only the first (outer) for loop works and just for the first item. The inner for loop will be ignored.</p>
  <p><a href="https://i.stack.imgur.com/vjBVl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vjBVl.png" alt="enter image description here" /></a></p>
  <p><strong>Result after update:</strong>
  <a href="https://i.stack.imgur.com/ihvDb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ihvDb.png" alt="enter image description here" /></a></p>
  <p><strong>Input data:</strong>
  This are the input data: <a href="https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items" rel="nofollow noreferrer">https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items</a></p>