Question: I am making a python flask trivia website. The following code is for the leaderboard. It is supposed to put it in descending order by
I am making a python flask trivia website. The following code is for the leaderboard. It is supposed to put it in descending order by score but it isn't working for some reason. How do I fix this?

Python Flask:
@app.route("/leaderboard") def leaderboard(): con = sqlite3.connect("scores.db") con.row_factory = sqlite3.Row cur = con.cursor() cur.execute("SELECT username, password, score, index1, answer, message FROM scores ORDER BY score DESC"); con.commit() cur.execute("select username,score from scores"); con.commit() rows = cur.fetchall(); return render_template("leaderboard.html",rows = rows)
HTML:
{% extends "layout.html" %} {% block content %} div class="leaderboard"> body> table border = 1> thead> td>Usernametd> td>Scoretdthead> {% for row in rows %} tr> td>{{row["username"]}}td> td>{{row["score"]}}td> tr> {% endfor %} table> body> div> {% endblock %}Username Score John Larry 45 Jenn John Larry 45 Jenn testerl11 0 tester121 -600 145 75 145 75
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
