Reputation: 6196
I have a list of lists
list = [[1,2,3],[4,5,6],[7,8,9]]
How do I display the second value from each list in a template: 2, 5, 8?
<div>
<ul class="list-group">
{% for item in list %}
{{ item[1] }},
{% endfor %}
</ul>
</div>
Upvotes: 1
Views: 1702
Reputation: 3591
You have to use dot notation to access list items:
<div>
<ul class="list-group">
{% for item in list %}
{{ item.1 }},
{% endfor %}
</ul>
</div>
Upvotes: 5