How do I create a leaderboard in python?
I am trying to create a leaderboard for python and cannot figure it out. I want the leaderboard to be sortable and in this format:
Score | Name
Can anyone help me?
Answered by Coder100 [earned 5 cycles]
The code is going to be something like this:
users = [("username", 5), ("someone", 15), ('n00b', 0)] # Sort user array users.sort(key=lambda a: a, reverse=True) # Format the users leaderboard = map(lambda user: user + "| " + str(user), users) # Output print("\n".join(leaderboard))
Hopes this helps!