[FIXED] How to access and display specific list item in flask


Like Python, you can access list elements by specifying their position. Can I do something similar with Flask


definition line ():
list = [1,2,3,4,5]
return render_template('list.html',list=list)


{% for item in list %}
  • {{item}}
  • {% end for %}

    As you know, the above line prints the entire list.
    But can I print only the item of the list in the second position

    Something like:

    {% for item in list %}
  • {{item[2]}}
  • {% end for %}

    Display only:


    Any ideas?? How to do it in flask using Jinja templates


    here is your answer


    No need to print the whole list if you don’t want to, just pass the index.

    Answered By – Bramhesh Srivastava

    Answer Checked By – Cary Denson (Easybugfix Admin)

    Leave a Reply

    (*) Required, Your email will not be published