0

This is the game I have created. It should add a new score to the file, but instead it just overwrites it, and I don't know how how to fix it.

    input("HIT ENTER WHEN YOU ARE READY")



    #Makes the while Statment repeating it selve
    c= True

    #Repeating it selve
    while c == True:

      import time

      One = time.time()
      a=input("Type as fast the alphabet (Either Caps or all small letters!):  ")
      b= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
      d= 'abcdefghijklmnopqrstuvwxyz'



      if a == b or a == d:
        Two = time.time()
        difference = int(Two - One)
        print("Well done your time is",difference,"seconds")
        c = False
      else:
        print('Arg Wrong the time is still running!')
        a=input(" ")
        C = True




    #Writes the sore to a file
    "Score.txt"

    def writeToFile():
      global myFile

    difference = str(difference)
    myFile = open("Score.txt","w")
    myFile.write(difference + '\n')
    myFile.close()
chepner
  • 497,756
  • 71
  • 530
  • 681

1 Answers1

0

When you open a file with w as mode, you overwrite it.

You should open the file using a to append your text to the end of the file.