MCPcopy Index your code
hub / github.com/geekcomputers/Python / load_high_score

Method load_high_score

Snake Game Using Turtle/scoreboard.py:25–31  ·  view source on GitHub ↗

Loads high score from highscore.txt. Returns 0 if not found.

(self)

Source from the content-addressed store, hash-verified

23 self.update_scoreboard()
24
25 def load_high_score(self):
26 """Loads high score from highscore.txt. Returns 0 if not found."""
27 try:
28 with open("highscore.txt", mode="r") as file:
29 return int(file.read())
30 except (FileNotFoundError, ValueError):
31 return 0
32
33 def update_scoreboard(self):
34 """Clears and rewrites the score and high score in the top-left corner."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected