0
How can I create a highscore function?!
I created a game and would like to add a highscore function, I have tried to use the shelve module, pickle, and even simple I/O but I keep getting an error. If anyone would like to help it would be welcomed. The link to the code is below. https://code.sololearn.com/cPLlr7q4eI7x/#py
5 ответов
+ 3
We don't want to view the code, we need to study it for accurate answer ^^
+ 2
We cannot guess that you've edited the question to add the code link ^^
Isn't the error message provided by running your code explicit enough? You're trying to use a "high_score" undefined variable...
Before using any variable you must define it by assigning some value: "high_score" identifier appears only once, where you get the error! So what are you expecting to get as value? You must handle some logic to have something to print as "high_score" in addition to declare it, or at least assign some arbitrary value to it before using it.
Anyway, what's the purpose of having a player highscore, when the code logic allow only once play and then exit on game over? To keep trace of scores and/or highscores across each code run, you need to save those values for example in a file wich is read at code start to initialize the related variables, and maybe ask for player name to be be able to refer to a specific player's highscore rather than all players highscore...
0
ok but first we need to analyze the code to be accurate
0
3 years later...
Ok have visph and Nushan Kodikara studied it?
- 1
yeah I need the code