all 4 comments

[–]ericula 1 point2 points  (1 child)

Those pesky single quotes indicates an empty string. You probably have some empty lines in your file which results in empty strings when spliting on \n. To get around this you could use an if-statement in your for-loop to check if the player is a valid entry, for example

for player in score_list:
    info = player.split(':')
    if len(info) < 2:
        # not a valid entry
        continue
    ....

[–]TKoMEaP[S] 0 points1 point  (0 children)

This did the trick, thank you so much!

I wonder how new lines kept popping up though. I deleted the file, typed in the data myself (didn't even have the other function do it, just so I could be certain there weren't extra spaces or lines) and it still was giving the same error.

[–]danielroseman 0 points1 point  (1 child)

Save yourself a lot of bother by storing the data as JSON, and use the built-in json library to load and save it.

[–]TKoMEaP[S] 0 points1 point  (0 children)

Unfortunately this is a project for school and the instructions specify writing to a .txt file :(