Home > Software design >  Using indexes of a list passed from flask in html
Using indexes of a list passed from flask in html

Time:08-24

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]

CodePudding user response:

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.

  • Related