Day 049 - Project 49 : Loading a High Score Table

If you have any questions, comments or issues with this project please post them here!

Hello, I’m having an error when trying to load the high.scores file from Day 49 on 100 days of code(for Python). Everything appears to be ok and I’m not sure what I’m doing wrong. I can link my replit to the forum for help.

1 Like

You must make a file named high.score. Also, welcome to community @sonicx180 !

you beat me again. Next time, mention me at the top of your post :slight_smile:


Hi! Thank you for welcoming me to the community and for the quick reply. I’m still not clear about what I’m doing wrong.

I thought I loaded the file, but I’m still getting an error message about it loading.

yes, you just need to make a file, try press the file icon that has a plus in it, and then make a file named high.score and put a bunch of numbers (scores) in it :smiley:

like this:

John Smith 100
John Doe 200

EDIT: reveal this by closing the tutorial and pressing the reveal sidebar


OK. I’ll try again. I understand that in theory but it hasn’t been working with the code. This is the first time I’ve gotten stuck.

1 Like

Hey there, the code provided is wrong, you are correct! Try this:

import os, time

f = open("high.score", "r")
scores ="\n")

highscore = 0
name = None

for rows in scores:
  data = rows.split()
  if data != []:
    if int(data[-1]) > highscore:
      highscore = int(data[-1])
      name = " ".join(data[:-1])

print("The winner is", name, "with", highscore)

Here: you can fork

1 Like

I managed to fix it!

Thank you for the feedback and the new code, it was very helpful. I’m completely self-taught and I’m sure my process would be faster if I asked for more help along the way. Getting help was easier than I expected it to be. Thanks again!!

1 Like

you’re welcome, hope you enjoy the community :smiley:

1 Like

Hi, not sure if this is a bug or I’m doing something wrong. I’ve opened the high.score file that was provided, you can see it open on the bottom tab but whenever I try to run the code, it says no such file or directory.

the thing has the wrong code sadly, to fix this either:

  1. or just put this in
f = open(".tutorial/high.score", "r")
  1. create a NEW file called high.score and put:
DMO 20332
K8T 398398398938
BRI 323232
SAM 494949

like this: