Reputation: 1100
This is a python in html related problem.
I have a python script with a list named scalar_not_adv_row
and tpdob.scalar_not_adv
.
Both the lists have same number of rows. But the code below is throwing syntax error. I am not able to understand why.
It is showing the error for row_num=${tpdob.scalar_not_adv_row[${i}]}
, where I want to get a particular element from the list without looping through it. Looping through both the lists will increase time complexity of the code and thus, I am trying to avoid it.
Please provide any suggestions you have to make the code work! And please tell if you have come across any website which can tell in detail how to use python in html!
<table>
% for COMPNAME in tpdob.scalar_not_adv:
<% i=0 %>
<% row_num=${tpdob.scalar_not_adv_row[${i}]} %>
<tr>
<td>${row_num}</td>
<td>${COMPNAME}</td>
</tr>
<% i=i+1 %>
% endfor
</table>
Upvotes: 1
Views: 62
Reputation: 186
Replace <% row_num=${tpdob.scalar_not_adv_row[${i}]} %>
with <% row_num=tpdob.scalar_not_adv_row[i] %>
. And it will work fine :)
Upvotes: 2