cannot display a line by line list on flask webpage


this is the function i used to return the list line by line :

def listing(table):
    for item in range(0,len(table)):
        result= f'{x}- {table[item]}' 
    final = '\n'.join(tab)
    return final

and i made sure that it is printing line by line in the terminal

this is the app.route :

if request.method=='POST':
    word = request.form['kword']
    return render_template('advance_search.html',key=table)
return render_template('advance_search.html')

and this is the placeholder i’m trying to display the result in it :

<div class="row center">

the result is displayed in the terminal line by line like desired, but on the webpage it is all concatinated side by side

can anyone help please ?


Rather joining the list with \n, join it with <br> , <br> tag means break line.

final = '<br>'.join(tab)

Use safe filter to render it as html rather then plain text.


Answered By – charchit

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published