Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- highscorefile = open("highscore.txt", "r") #high score is retrieved
- highscore = int(highscorefile.read())
- highscorefile.close()
- if score >= highscore: #high score is adjusted
- highscore = score
- highscorefile = open("highscore.txt", "w") #highscore is saved in highscore.txt
- highscorefile.write(f"{highscore}")
- highscorefile.close()
- highscorefile = open("highscore.txt", "r") #(new) high score is displayed
- print(f'The highscore is {highscorefile.read()}! ')
- highscorefile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement