I have a .txt file that is being written to by a python script.
Adam,3,2,4
Sorin,3,2,4
Sorin,0,0,0
new_record = studentName+","+str(Score1) +","+str(Score2) +","+str(Score3)
student_class = 0
while student_class != 1 or student_class != 2 or student_class != 3:
student_class=input("What class are you in?(1/2/3): ")
if student_class == "1":
file=open("Class1.txt", "a+")
file.write(new_record)
file.write("\n")
file.close()
with open("Class1.txt", 'r') as fp:
for count, line in enumerate(fp):
pass
break
I want the scores to be overwritten if the student name is the same. For example if I run the script again, and Sorin gets a score of "3,3,3" the .txt file would look like this:
Adam,3,2,4
Sorin,3,2,4
Sorin,0,0,0
Sorin 3,3,3
However I want it to turn out like this:
Adam,3,2,4
Sorin 3,3,3