Thursday, 19 September 2013

Writing a Top Score to a data file

Writing a Top Score to a data file

I am trying to create a file that will hold just one number; the highscore
to a game I am writing.
I have
f = open('hisc.txt', 'r+')
and
f.write(str(topScore))
What I want to know how to do is to:
Erase the entire file Get the number in the file and make it a variable in
the game Check if the topScore is higher than the number in the file, and
if so, replace it

No comments:

Post a Comment