title: For loop for a dictionary
body: <p><strong>EDIT BELOW</strong></p>
  <p>I have a big dictionary containing information about lots of clusters and their genes. I'm trying to access part of the data about 'cdhitclusters'. This section of code works perfectly and does exactly what I want it to do (counting the number of rep_genes per cluster). I just don't know how to write a for loop to do this for all the clusters in the dictionary.</p>
  <pre><code>clus1 = (gene_clusters.get(&quot;cluster-1&quot;))
  cdhit1 = (clus1.get(&quot;cdhitclusters&quot;))
  rep1 = pd.DataFrame(cdhit1)
  print(len(rep1.rep_gene))
  </code></pre>
  <p>Here's a section of the dictionary:</p>
  <pre><code>{
      'cluster-1': {
          'BGCid': '-',
          'cdhitclusters': [
              {
                  'genes': { 'AT1G24070': 100.0 },
                  'rep_gene': 'AT1G24070'
              },
              {
                  'genes': { 'AT1G24100': 100.0 },
                  'rep_gene': 'AT1G24100'
              },
              {
                  'genes': {
                      'AT1G24040': 100.0,
                      'AT1G2404_1': 100.0,
                      'AT1G2404_2': 100.0
                  },
                  'rep_gene': 'AT1G24040'
              },
              {
                  'genes': {
                      'AT1G24020': 100.0,
                      'AT1G2402_1': 100.0
                  },
                  'rep_gene': 'AT1G24020'
              },
              {
                  'genes': { 'AT1G24010': 100.0 },
                  'rep_gene': 'AT1G24010'
              },
              {
                  'genes': { 'AT1G24000': 100.0 },
                  'rep_gene': 'AT1G24000'
              }
          ]
      ...
  </code></pre>
  <p>There are 45 clusters, how can I write a loop to do as the code above does, but for all the clusters?</p>
  <p><strong>UPDATED</strong></p>
  <p>Thank you for the answers, they worked. I want it to output to a dataframe that I can add to a larger data frame. This is the code I'm using, but it only calculates the CDhit for the first cluster in the loop. What am I doing wrong?</p>
  <pre><code>for clus in gene_clusters.values():
      cdhit = (clus.get(&quot;cdhitclusters&quot;))
      rep = pd.DataFrame(cdhit)
      replen = rep.iloc[:,0]
      replen1 = len(rep.rep_gene)
      list = [replen1]    
      replen2 = pd.DataFrame(list, columns=['CDhits'])
      replen2 = replen2.CDhits
  </code></pre>