1``range`` 2========= 3 4Returns a list containing an arithmetic progression of integers: 5 6.. code-block:: jinja 7 8 {% for i in range(0, 3) %} 9 {{ i }}, 10 {% endfor %} 11 12 {# outputs 0, 1, 2, 3, #} 13 14When step is given (as the third parameter), it specifies the increment (or 15decrement for negative values): 16 17.. code-block:: jinja 18 19 {% for i in range(0, 6, 2) %} 20 {{ i }}, 21 {% endfor %} 22 23 {# outputs 0, 2, 4, 6, #} 24 25.. note:: 26 27 Note that if the start is greater than the end, ``range`` assumes a step of 28 ``-1``: 29 30 .. code-block:: jinja 31 32 {% for i in range(3, 0) %} 33 {{ i }}, 34 {% endfor %} 35 36 {# outputs 3, 2, 1, 0, #} 37 38The Twig built-in ``..`` operator is just syntactic sugar for the ``range`` 39function (with a step of ``1``, or ``-1`` if the start is greater than the end): 40 41.. code-block:: jinja 42 43 {% for i in 0..3 %} 44 {{ i }}, 45 {% endfor %} 46 47.. tip:: 48 49 The ``range`` function works as the native PHP `range`_ function. 50 51Arguments 52--------- 53 54* ``low``: The first value of the sequence. 55* ``high``: The highest possible value of the sequence. 56* ``step``: The increment between elements of the sequence. 57 58.. _`range`: https://secure.php.net/range 59