You have a missing quote to close the first word apples. Fixed code:
{% set items= ['apples', 'oranges', 'bananas', 'pears'] %}
{% for item in items %}
{% if loop.index == 2 %}
{% set output = item %}
{{ output|pprint }}
{% endif %}
{% endfor %}
Also, to print just the value you don't need the |pprint filter. Its used to print a whole array and the type of the function and things like that while debuggin. In this case the |pprint filter will print: (String: oranges)
instead only: orange
Regards,
Gonzalo
If this answer helps you to solve your questions please mark it as a solution.
You have a missing quote to close the first word apples. Fixed code:
{% set items= ['apples', 'oranges', 'bananas', 'pears'] %}
{% for item in items %}
{% if loop.index == 2 %}
{% set output = item %}
{{ output|pprint }}
{% endif %}
{% endfor %}
Also, to print just the value you don't need the |pprint filter. Its used to print a whole array and the type of the function and things like that while debuggin. In this case the |pprint filter will print: (String: oranges)
instead only: orange
Regards,
Gonzalo
If this answer helps you to solve your questions please mark it as a solution.