0

Storing high scores

I am making a small game for my programming class and would like to have a leaderboard system recording how fast a user can complete the game. Is there a way to record multiple scores and store them so it saves each time the program is run?

6th Oct 2019, 2:23 PM
Advanced Incognizant
2 Respuestas
+ 3
You can store scores in a file then load them using open(file,method)
6th Oct 2019, 5:09 PM
Sousou
Sousou - avatar
+ 3
You can use a simple list to keep the scores. They have a sort method, so you can sort them from biggest to lowest easily and keep only the first ten elements (or how long you want your best times list to be). Using the module pickle, you can save and load that list easily and conveniently.
6th Oct 2019, 2:48 PM
HonFu
HonFu - avatar