for key twig code example
Example 1: twig for
<ul>
{% for key, user in users %}
<li>{{ key }}: {{ user.username|e }}</li>
{% endfor %}
</ul>
Example 2: twig loop variables
{% for user in users %}
{{ loop.index }} - {{ user.username }}
{% endfor %}
Example 3: how to for loop twig
{% for letter in 'a'..'z' %}
* {{ letter }}
{% endfor %}