Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. highscorefile = open("highscore.txt", "r")    #high score is retrieved
  2. highscore = int(highscorefile.read())
  3. highscorefile.close()
  4.  
  5. if score >= highscore:                        #high score is adjusted
  6.     highscore = score
  7.  
  8. highscorefile = open("highscore.txt", "w")    #highscore is saved in highscore.txt
  9. highscorefile.write(f"{highscore}")
  10. highscorefile.close()
  11.  
  12. highscorefile = open("highscore.txt", "r")    #(new) high score is displayed
  13. print(f'The highscore is {highscorefile.read()}! ')
  14. highscorefile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement