code: def write_table(page, headers, data, cl=''):
  
      
  
      page.table(class_=cl)
  
      # list
      if cl=='list':
          for i in range(len(headers)):
  
              page.tr()
              page.th()
              page.add('%s' % headers[i])
              page.th.close()
              page.td()
              page.add('%s' % data[i])
              page.td.close()
              page.tr.close()
  
      else:
          page.tr()
          for n in headers:
              page.th()
              page.add('%s' % n)
              page.th.close()
          page.tr.close()
  
          if data and not re.search('list',str(type(data[0]))):
              data = [data]
  
          for row in data:
              page.tr()
              for item in row:
                  page.td()
                  page.add('%s' % item)
                  page.td.close()
              page.tr.close()
  
      page.table.close()
  
      return page
docs: Write table in html