I have a variable questionCount
which is passed to the HTML page and used to create row column entries in a table. This number can vary and needs to be used in a for loop.
I need to do something like the following:
{% for num in 1..questionCount %}
<td>Question {{num}}</td>
{% endfor %}
But this does not work. What is the appropriate way to do this?
1..questionCount
is not valid Python (but Ruby).
Try range(1, questionCount + 1)
instead to generate values from 1 to questionCount
. See also the docs about range
.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加