I have a file that includes student IDs and their scores. I'm trying to create a file with the name usoscorelist.txt
and write the inside of the scorelist.txt
in it, changing the score of the student 151133 from 40 to 100. I think the space between the ID and the score is making a problem here. I'm not getting any errors nor seeing any changes in the file.
with open('scorelist.txt','r') as firstfile, open('usoscorelist.txt','r+') as secondfile:
for line in firstfile:
secondfile.write(line)
for line in secondfile:
print(line.replace(151133 + " " + 40, 151133 + " " + 100))
secondfile.close()
The inside of scorelist.txt is:
121787 74
121367 71
121817 88
121619 85
131445 80
131244 96
131872 98
131963 75
131172 78
131965 72
131112 90
131956 87
141105 61
141703 61
141407 78
141569 82
141585 89
141455 82
141370 80
141837 67
141857 86
141497 94
141853 67
141245 80
151452 83
151238 62
151827 58
151409 40
151789 95
151742 71
151133 40
151095 49
151186 75
151586 51
151926 73
151975 96
151079 49
151091 100
151588 49
151630 61