How can I do for-loop like this in Django?
list = ['AAA', 'BBB', 'CCC']
==========================================
{% for x in len(list), for y in list %}
<p>{{x}}: {{y}}</p>
{% endfor %}
How can I do for-loop like this in Django?
list = ['AAA', 'BBB', 'CCC']
==========================================
{% for x in len(list), for y in list %}
<p>{{x}}: {{y}}</p>
{% endfor %}
 
    
    The best option is the enumerate function.
return render_template("index.html", list=enumerate(list))
Then in the template:
{% for index, value in list %}
    <p>{{index}}: {{value}}</p>
{% endfor %}
