leaderboard = open("scores.txt", "r")
scores = leaderboard.readlines()
rawscores = []
for lines in scores:
details = lines.rstrip("\n") #removes empty space
details = details.split(",") #splits apart data with a comma at each space
details[0] = int(details[0])
rawscores.append(details)
rawscores.sort(key=lambda x: x[0], reverse=True) #sorts data from highest to lowest
print("1. "+str(rawscores[0][0]),"done by",str(rawscores[0][1]))
print("2. "+str(rawscores[1][0]),"done by",str(rawscores[1][1]))
print("3. "+str(rawscores[2][0]),"done by",str(rawscores[2][1]))
print("4. "+str(rawscores[3][0]),"done by",str(rawscores[3][1]))
print("5. "+str(rawscores[4][0]),"done by",str(rawscores[4][1]))
twitch1411 0 Newbie Poster
rproffitt 2,693 https://5calls.org Moderator
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.