The following code displays different values of x in different months. Set command of jinja2 works for flag,x but not for total. Why?
{% set flag = 1 %}
{% set total = 0 %}
{% for date in dates %} //dates is some array
{% if flag == 1 %}
{{x}}
{% set flag= 0 %} // I have used 1+1 also that too works
{% elif "Jul" in date %}
{% set x = x*3 %}
{% if x % 10!=0 %}
{% set x = x - x % 10 %}
{% set total = total + x %}
{% endif %}
{% else %}
{{x}}
{% set total = total + x %}
{% endif %}
{% endfor %}
{{total}}