I'm having trouble appending the values from a list of lists into a html table, for example my list if lists contains:
food_list = [['A','B'], ['Apple','banana'], ['Fruit','Fruit']]
How would i append each value into a correspondong HTML table? So the code looks like:
<table>
<tr><td>A</td><td>Apple</td><td>Fruit</td></tr>
<tr><td>B</td><td>Banana</td><td>Fruit</td></tr>
</table>
the closest i could get was with the code below, but i get a list index out of range error.
print '<table>'
for i in food_list:
print '<tr>'
print '<tr><td>'+i[0]+'</td><td>'+i[1]+'</td><td>'+i[2]+'</td></tr>'
print '</tr>'
print' </table>'
[['A','Apple','Fruit'],['B','banana','Fruit']]. That way each row logically corresponds to one "thing" (i.e. a row for the apple, a row for the banana, etc.), plus the code you were trying to use would have worked.