title: Creating a HTML Table with Python
body: <p>I'm stuck on creating a HTML Table for this code here. have to try to output all the <code>dir()</code> of <code>list</code>, <code>dict</code>, <code>tuple</code>, <code>str</code>, <code>int</code>, and <code>float</code> in a HTML table with a limit of 7 column per row. I've tried many things and is unable to produce that. I kept getting an internal server error when i try it out. I think i'm doing the tags from for the table or i'm missing something but still haven't figured it out.</p>
  
  <pre><code>#!/usr/local/bin/python3
  
  print('Content-type: text/html\n')
  
  d_list = [] 
  d_dict = []
  d_tuple = []
  d_str = []
  d_int = []
  d_float = []
  
  for i in dir(list):
      d_list.append(i)
  for i in dir(dict):
      d_dict.append(i)
  for i in dir(tuple):
      d_tuple.append(i)
  for i in dir(str):    
      d_str.append(i)
  for i in dir(int):
      d_int.append(i)
  for i in dir(float):
      d_float.append(i)
  
  d_list = [d_list[i:i + 7] for i in range(0, len(d_list), 7)]
  d_dict = [d_dict[i:i + 7] for i in range(0, len(d_dict), 7)]
  d_tuple = [d_tuple[i:i + 7] for i in range(0, len(d_tuple), 7)]
  d_str = [d_str[i:i + 7] for i in range(0, len(d_str), 7)]
  d_int = [d_int[i:i + 7] for i in range(0, len(d_int), 7)]
  d_float = [d_float[i:i + 7] for i in range(0, len(d_float), 7)]
  
  td_list = []
  td_dict = []
  td_tuple = []
  td_str = []
  td_int = []
  td_float = []
  
  for i in d_list:
       td_list.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  for i in d_dict:
       td_dict.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  for i in d_tuple:
       td_tuple.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  for i in d_str:
       td_str.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  for i in d_int:
       td_int.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  for i in d_float:
       td_float.append(['&lt;td&gt;{}&lt;/td&gt;'.format(x) for x in i])
  
  &lt;table&gt;
  for i in td_list:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  &lt;table&gt;
  for i in td_dict:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  &lt;table&gt;
  for i in td_tuple:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  &lt;table&gt;
  for i in td_str:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  &lt;table&gt;
  for i in td_int:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  &lt;table&gt;
  for i in td_float:
       print('&lt;tr&gt;' + " ".join(i) + '&lt;/tr&gt;')
  &lt;/table&gt;
  </code></pre>