I am trying to render all the elements in my array when there is an element there and when there isn't. When there isnt an element at that position I want to display that there isnt an exercise(element) at that position. This requires a short bit of code which works in python but not in Jinja. Which doesn't make sense to me unless I am missing a difference between the two languages.
The reason I wrote out the code in python first is because I have been trying for a while to get this working. I thought if I wrote the python I could translate it but I guess not?
Working python code:
dailyExercise = [('Exercise 1', 1), ('Exercise 2', 3)]
for x in range(dailyExercise[-1][-1]):
    print(x+1)
    isExercise = False
    for exercise in dailyExercise:
        if exercise[-1] == x+1:
            print(exercise[0])
            isExercise = True
            break;
    if isExercise == False:
        print("no exercise")
Not working Jinja code:
{% for x in range(dailyExercise[-1][-1]) %}
    <p>Day {{x+1}}</p>
    {%set isExercise = False%}
    {% for exercise in dailyExercise%}
        {% if exercise[-1] == x+1 %}
            {%set isExercise = True%}
            <p>{{exercise[0]}}</p>
        {% endif %}
    {% endfor %}
    {% if isExercise == False%}
    <p>no exercise</p>
    {% endif %}
{% endfor %}
Python prints this:
1                                                                      
Exercise 2                                                             
2                                                                      
no exercise                                                            
3                                                                      
Single leg balance abd/adduction 
Jinja renders this:
Exercise 2
no exercise
Day 2
no exercise
Day 3
Single leg balance abd/adduction
no exercise
 
    