Skip to content
Is there a way to get the highest value stored in the repl database?
Profile icon

I want to make a leaderboard for my game that displays people with the highest number of coins.

You are viewing a single comment. View All
Profile icon

Yes, it is possible.

scores = [] leaderboard = {} for key in db.keys(): scores.append(db[key]) highscore = max(scores) for key in db.keys(): if db[key] == highscore: leaderboard[key] = db[key] scores.pop(leaderboard[key]) highscore = max(scores)

Assuming that the key is the username, and db[key] is their highscore, then this would sort it in order.

Now you can mark it as answered, thank you!