You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{% set c = 0 %}
{% for n in n_list %}
{% if loop.index % 3 == 0 %}
{% else %}
{% set l = range(3, 6) | random %}
{% set c = c+l %}
{% endif %}
{{ loop.index }} {{c}} {{l}}<br>
{% endfor %}
{% set c = 0 %}
{% for n in n_list %}
{% if loop.index % 3 == 0 %}
{% else %}
{% set l = range(3, 6) | random %}
{% set c = c+l %}
{% endif %}
{{ loop.index }} {{c}} {{l}}<br>
{% endfor %}
Your Environment
Python version: 3.6.0
Jinja version: 2.9.5
The text was updated successfully, but these errors were encountered:
I am setting jinja2 variable outside (before) the loop, yet it is being resetted every time the loop is being iterated.
Also asked at stackoverflow: http://stackoverflow.com/questions/43061439/jinja2-variable-wont-update-in-a-loop-based-on-operation-performed-as-expected
I have this following code:
Expected Behavior
1 3 3
2 7 4
2 7 0
2 11 4
...
Actual Behavior
1 3 3
2 4 4
3 0
4 4 4
5 5 5 # ...
6 0
7 5 5
8 5 5
9 0
10 4 4
Template Code
Your Environment
The text was updated successfully, but these errors were encountered: