Bootstrap FreeKB - Jinja - Count the number of elements in a list
Jinja - Count the number of elements in a list

Updated:   |  Jinja articles

Here is a basic example of how to create and print a list in Jinja.

{% set fruits=['apple','banana','grape','orange'] %}
{{ print fruits }}

 

length can be used to get the count of elements in a list. 

{% set fruits=['apple','banana','grape','orange'] %}
There are {{ print fruits|length }} elements in the fruits list

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 54e097 in the box below so that we can be sure you are a human.