samedi 22 juillet 2017

Printing more than one image (per line) in flask

I am having trouble with an application that I built. Basically what it does is if it detects the name of a country in a string(submission.title), then it will print the flag of that country after the title. So if the title was 'China is building a rocket' it would have the Chinese flag printed right after the word rocket. The problem is that it won't print more than one flag. So if the title was 'China and Russia are building rockets' it would only print either the Chinese flag or the Russian flag. Not both. I want it to be able to print both flags.

Thank you

Python script

news = []
i = 0
for submission in redditFunction(time, limit=int(num) ):
    i += 1
    for j in country: #j = country name
        if j in submission.title: 
            flag = "static/flags/" + country[j].lower() + ".png"
            news.append([str(i) + '. ' + submission.title, submission.url, flag] )
            break
    else:
        news.append([str(i) + '. ' + submission.title, submission.url]) #leave this blank

return render_template("index.html", news=news)

HTML






Aucun commentaire:

Enregistrer un commentaire