What does {% for myuser in users if not myuser == "root" %} do, and what does loop.index count in that loop?
The if after the list filters the loop: root is skipped as if it weren't in the list, and loop.index counts only the elements that pass, so the numbering has no gap.
* An inline if filters first; loop.index numbers what is left. *
{# for statement #}
{% for myuser in users if not myuser == "root" %}
User number {{ loop.index }} - {{ myuser }}
{% endfor %}
With users: [alice, root, bob] the result is:
User number 1 - alice
User number 2 - bob
This is different from putting an {% if %} inside the loop body. There, root would still be an iteration: it would be skipped in the output, but loop.index would have moved on, so bob would be number 3. The inline filter is the clean way to say "loop over these elements, except ...". myuser != "root" is an equivalent, shorter condition.
(Checked with Jinja2 3.1.)
Go deeper:
Template Designer Documentation: loop filtering (Jinja) โ filtering in the
forstatement and how it affects the loop variables.