saving last results in a text file
<p>the problem i have is that i have a quiz which the user can pick from 3 classes. they then proceed to complete the quiz and currently their name and score is saved into a text file for the correct class (there are 3 different files for the 3 different classes). but how do i make it so if the same user has completed the quiz that only the last 2 scores that the student obtained is saved in the file rather than all of the scores.</p>

<pre><code>if classChoice ==1:
        File=open("A.txt","a+")
        File.write(names+","+str(score)+"\n")
        File.close()

if classChoice ==2:
        File=open("B.txt","a+")
        File.write(names+","+str(score)+"\n")
        File.close()
if classChoice ==3:
        File=open("C.txt","a+")
        File.write(names+","+str(score)+"\n")
        File.close()
</code></pre>