title: use python to dynamically create html grid for row and col
body: <p>I am trying to create a row and col grid using python. The basic's is that for the first element in the userName list I should be creating a <code>&lt;div class="row"&gt;</code>then ideally every forth iteration of the loop I should be closing that row with another div. </p>
  
  <p>The part that is kind of tricking me is if there are say less that 4 elements in the list than I will still need to close the row with another div properly if I am only having say 3 elements in the list or 2 elements in the list.</p>
  
  <p>Hopefully I explained that well enough, please ask question and I will explain what I mean again.</p>
  
  <pre><code>    # userName = ['Name1', 'Name2']
      userName = ['Name1', 'Name2', 'Name3', 'Name4', 'Name5', 'Name6', 'Name7', 'Name8']
      # userName = ['Name1', 'Name2', 'Name3']
  
      html_card = ''
      for count, element in enumerate(userName, 1): # Start counting from 1
  
          # ADDING HTML ROW
          if count % 4 == 0 or count == 1:
              html_card += '&lt;div class="row"&gt;'
  
          # ADDING HTML CARD COL
          html_card += '''\n&lt;div class="col"&gt;
                          &lt;div class="card card-block"&gt;
                            &lt;div class="card mb-4 border-primary"&gt;
                                  &lt;div class="card-header bg-primary"&gt;{element}&lt;/div&gt;
                                  &lt;div class="card-body text-primary"&gt;
                                    &lt;h4 style="color:#0069d9" class="card-title"&gt;{element} Performance Runs&lt;/h4&gt;
                                    &lt;p style="color:#0069d9" class="card-text"&gt;&lt;/p&gt;
                                    &lt;button type="button" class="btn btn-primary" value="Show Div" onclick="showDiv()"&gt;Available Runs&lt;/button&gt;
                                  &lt;/div&gt;
                               &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;\n'''.format(element=element)
  
          # ADDING HTML ROW DIV
          if count % 4 == 0 or element == userName[-1]:
              html_card += '&lt;/div&gt;\n'
  
          print(html_card)
  </code></pre>