Aug 22, 2024
readlines() and writelines().myfile.txt.f = open('myfile.txt') to open the file and read lines.for line in f:
print(line)
56, 45, 67
12, 34, 63
13, 64, 23
line.split(',') to extract individual marks.i to keep track of student numbers.int(value) * 2 for calculating percentages.*myfile2.txt.f.writelines(lines) to write lines to the file.writelines() does not add newline characters automatically; you must handle that manually.lines = ['line 1', 'line 2', 'line 3']
f.writelines(lines) # No automatic new line