I'm trying to make a table showing different values in each cell, and depending on the value of cell, have a different bgcolor.
So I have managed to do this successfully with one column by using a simple loop, but I cannot figure out a way to do this with multiple columns holding the same pattern. I am not very experienced and any help is appreciated.
import HTML
test_results = [
70,
50,
20,
5,
]
t = HTML.Table(header_row=['test'])
for new in sorted(test_results):
#print new
if new <=50:
color = 'yellow'
elif new <=100:
color = 'blue'
elif new <=150:
color = 'green'
elif new >150:
color = 'white'
colored_result = HTML.TableCell(new, bgcolor=color)
t.rows.append([colored_result])
htmlcode = str(t)
print htmlcode
This produces a single column table but I would like to add more data and have a table of many rows and columns.