Using indexes of a list passed from flask in html

Question:

I’m trying to pass a list from flask via this code:

package1 = ['1', 'Jackson', 'newyork','No8', '+10880275896']
render_template("index.html", package1=package1)

on the other side I took the parameter into an html input to use it like this:

< input type="text" id="name" value="{{ package1}}" >

Please guide me anyone: "how I can access to the indexes in the HTML code"

meant for example using index 0 of the list:

package1[0]
Asked By: Mohsen Saeidzadeh

||

Answers:

You can refer to the first element in the list with:

<input type="text" id="name" value="{{ package1[0] }}" >

This will render ‘1’ as the value of the input tag.

Answered By: rockstaedt
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.