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]))

From your other post:

So I'm doing my CS NEA and I dont get what's wrong with my code here:

Since it is this you can't have folk write the code for you but you also need to do more than dump code and not write what the issue is. You can't lead with "it doesn't work" or similar. No one by you knows what this is supposed to do as we don't have access to the design spec.

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.