Python: For loop problem

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-03-12T13:39:10Z Indexed on 2010/03/12 13:47 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

I have a PSP page with html embedded. I need to place another for loop so i can insert another %s next to background-color: which will instert a appropriate colour to colour in the html table.

For example i need to insert for z in colours so it can loop over the colours list and insert the correct colour. Where ever i try to insert the for loop it doesnt seem to work it most commonly colours each cell in the table 60 times then moves onto the next cell and repeats itself and crashes my web browser.

The colours are held in a table called colours.

code below:

<table>
<%
s = ''.join(aa[i] for i in table if i in aa)
for i in range(0, len(s), 60):
    req.write('<tr><td><TT>%04d</td>' % (i+1));
    for k in s[i:i+60]:
            req.write('<TT><td><TT><font style="background-color:">%s<font></td>' % (k));
    req.write('</TT></tr>')
#end
%>
</table>

© Stack Overflow or respective owner

Related posts about python

Related posts about html