Twig: "for" does not display variable content without first displaying all variable content I have found a very strange behavior.

My variable related_nodes contains a list of nodes. How it is displayed by Kint:

related_nodes array(10)
'#sorted' =&gt; boolTRUE
'#pre_render' =&gt; array(1)
'8' =&gt; array(5)
'10' =&gt; array(5)
'11' =&gt; array(5)
'12' =&gt; array(5)
'13' =&gt; array(5)
'14' =&gt; array(5)
'15' =&gt; array(5)
'16' =&gt; array(5)

If I first display the content the variable {{ related_nodes }}, it displays this all related nodes and then them one by one in Divs (with loop index before):

{{ related_nodes }}
            {% for rel_node in related_nodes[2:] %}
               &lt;div class="col-md-4 col-xs-6"&gt;{{ loop.index }} - {{ rel_node }}&lt;/div&gt;
            {% endfor %}

But when I remove the first display of the variable: {{ related_nodes }}, it does not display related nodes one by one in Divs (it displays only the loop indexes):

        `{% for rel_node in related_nodes[2:] %}
           &lt;div class="col-md-4 col-xs-6"&gt;{{ loop.index }} - {{ rel_node }}&lt;/div&gt;
        {% endfor %} `


I also have 8 errors like this:
"   Notice: Undefined index: title in template_preprocess_node() (line 616 of C:\Users\Oksana\Documents\sites\drupal2\core\modules\node\node.module)" when the {{ related_nodes }} is removed.

When I removed the slice [2:], it did not help.

Is there any need to pre-load a varible before I can iterate in it with the twig 'for'? Or what can be a reason for such behavior?

I need to remove this {{ related_nodes }} because it displays all vertically without formating in columns.

Drupal version: 8.5.3.
In Twig you could re-use the pre render callback for each single node, see Cycle comments on field--comment.html.twig, but since you are responsible for the content of the twig variable you can do this when preparing the variable by replacing viewMultiple() with multiple view():

foreach ($related_nodes as $node) {
  $variables['related_nodes'][] = \Drupal::entityTypeManager()
    -&gt;getViewBuilder('node')
    -&gt;view($node, $view_mode, $current_node-&gt;language()-&gt;getId());
}


Then in Twig you can use a normal loop:

        {% for rel_node in related_nodes %}
           &lt;div class="col-md-4 col-xs-6"&gt;{{ loop.index }} - {{ rel_node }}&lt;/div&gt;
        {% endfor %}