How do I use divisibleby() in a for loop to display two columns? I try to write a row in which there are two columns:

&lt;div class="row"&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="row"&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
&lt;/div&gt;
{# and so on and so on #}


Now maybe there is only one block_txt div at the end so I try to wrap the row tag in a devisibleby conditional to only write the row tag every second time, or at the end.
It looks like this:

{% for entry in entriesInYear %}
   {% if loop.index is divisibleby(2) or loop.first %}&lt;div class="row"&gt;{% endif %}
      &lt;div class="block_txt"&gt;This gets repeated n times&lt;/div&gt;
   {% if loop.index is divisibleby(2) or loop.last  %}&lt;/div&gt;{% endif %}
{% endfor %}


But that doesn't work the way I want. Every third block_txt isn't wrapped in a row. How do I have to math this? Or is there a better way to write the whole piece?
Instead of using the divisibleby-function you can use the batch-filter:

{% for row in entriesInYear|batch(2) %}
&lt;div class="row"&gt;
    {% for entry in row %}
        &lt;div class="block_txt"&gt;&lt;/div&gt;
    {% endfor %}
&lt;/div&gt;
{% endfor %}


If you have 3 entries in entriesInYear this code would output:

&lt;div class="row"&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="row"&gt;
   &lt;div class="block_txt"&gt;&lt;/div&gt;
&lt;/div&gt;