Home / Challenges / Query Top Scores from SQLite

Query Top Scores from SQLite

Medium
You have a SQLite table "scores" with columns (id, player, score). Write a function top_players(conn, limit) that returns the top `limit` players ordered by score descending, as a list of (player, score) tuples, using a parameterized query.

Input

A sqlite3 connection object and an integer limit.

Output

A list of (player, score) tuples, highest scores first.

Example

Input
top_players(conn, 2) with rows [("Alice",90), ("Bob",75), ("Carl",95)]
Output
[('Carl', 95), ('Alice', 90)]
15 XP on solve Back to lesson

Your Solution

Output
Click "Run" to execute your code...

Log in to submit your solution and earn XP.