Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I guess you want one color for each column. Best idea would be to use enumerate:</p> <pre><code>s = ''.join(aa[i] for i in table if i in aa) for i in range(0, len(s), 60): req.write('&lt;tr&gt;&lt;td&gt;%04d&lt;/td&gt;' % (i+1)) for j, k in enumerate(s[i:i+60]): req.write('&lt;td style="background-color: %s;"&gt;%s&lt;/td&gt;' % (colours[j % len(colours)], k)) req.write('&lt;/tr&gt;') </code></pre> <p>I stripped all the <code>TT</code> tags. They were mostly wrong, either not closed or spanning over other elements.</p> <p><strong>Update</strong> This should do. Take a look at the source, if every field is filled correctly. Also download <a href="https://addons.mozilla.org/de/firefox/addon/1843" rel="nofollow noreferrer">Firebug</a> and take a look at the parsed html code. It may differ depending on your other html failures.</p> <pre><code>colour = ["red", "red", "green", "yellow"] print "&lt;table&gt;" s = '1234567890' for i in range(0, len(s), 60): print('&lt;tr&gt;&lt;td&gt;%04d&lt;/td&gt;' % (i+1)); for j, k in enumerate(s[i:i+60]): print('&lt;td&gt;&lt;font style="background-color:%s;"&gt;%s&lt;font&gt;&lt;/td&gt;' % (colour[j % len(colour)], k)); print('&lt;/tr&gt;') print "&lt;/table&gt;" </code></pre> <p>I piped the output of the following code into a html file and opened it. Works as expected.</p> <pre><code>python table.py &gt; table.html firefox table.html </code></pre> <p>I guess you have some additional errors in your code which mess up parsing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload