title: Building a dynamic table with jinja2, html and flask
body: <pre><code>&lt;table style=&quot;width:100%&quot;, border=&quot;1&quot;&gt;
          {% for item in items %}    
          &lt;tr&gt;               
              &lt;td&gt;{{Description[item]}}&lt;/td&gt;
              &lt;td&gt;{{Location[item]}}&lt;/td&gt;
              &lt;td&gt;{{Status[item]}}&lt;/td&gt;                
          &lt;/tr&gt;
          {% endfor %}    
  &lt;/table&gt;
  </code></pre>
  <p>I am trying to create a table using this for loop, the variables are being passed through in the flask framework, 'items' will always be the same length as the three lists (Description, location and status).
  I am aware of the question below:
  <a href="https://stackoverflow.com/questions/9198334/how-to-build-up-a-html-table-with-a-simple-for-loop-in-jinja2">How to build up a HTML table with a simple for loop in Jinja2?</a></p>
  <p>but I can not see how my code here differs to the working answer to this question, is it because I am using a list instead of a dictionary ?</p>
  <p>This is the flask framework, where the lists
  are created an passed through using render template:</p>
  <pre><code>def index():
  description = []
  location = []
  status = []
  imix80m = ''
  imix = ''
  with open('behavepretty.json') as a:
      data = json.load(a)
      for n in range(0,len(data)):
          i = 0
          for i in range(0, len(data[n]['elements'])):
              x = data[n]['elements'][i]['name']
              description.append(x)
              y = data[n]['elements'][i]['location']
              location.append(y)
              z = data[n]['elements'][i]['status']
              status.append(z)
          n = 0
      for n in range(0,len(data)):
          if n == 0:
              imix80m = data[n]['status']
          elif n == 1:
              imix = data[n]['status']
  a.close()
  return render_template('trial.html', Description = description, Location= location, Status = status, result1 = imix80m, result2 = imix, jfile = data, items = description)
  </code></pre>