{% for s in '12345' %} {% if s <= score|stringformat:'d' %} {% else %} {% endif %} {% endfor %}