I have a list of this form in a .txt
file: student1, 2, 3 | student2, 1, 4
I need to call it in a program, add [student3, 3, 5]
to the list, and then save it back into the .txt
file. I did this but my list looked like this at the end: [[''], ['Student3', '3', '5']]
f = open('classe1.txt','r')
liste = f.read()
liste = liste.split('|')
n = len(liste)
for i in range (n):
liste[i] = liste[i].split(',')
liste.append(['Student3','3','5'])
liste = str(liste)
f = open('classe1.txt','w')
f.write(liste)
How would you do it ? Thank you !