i am currently working on a text based game, and have run into a problem trying to make my last function, highscore
.
My problem is this, i would like to make the function save my top five scores
and save it to a text file, along with the player's username
, and then be able to print this into my text based game.
I know this could be hard to do, but i would like it if the scores were saved in a text file, and not a pickle
as i have seen suggested, as i would like to share the file with some friends.
Any help is appreciated,
Thanks, Tom.
edit:
I am comfortable opening the file for writing. my code included the scores.sort
command, but i wasn't sure how to put 5 scores into the file, and have the 6th score deleted. Thanks for the help, Tom