def readFromFileself filename str read the student name and
def readFromFile(self, filename: str): \"\"\"read the student name and courses from the specified file and adds them to the list of courses:param filename: name of file to read the data from; the format of the file must match the format the writeToFile method produces \"\"\" f = open(filename, \'r\') c = file.readlines() self.none = c[0] for i in range(1, len(c)): self.addCourse(Course.fromCSV(c[i])) file.close()
Solution
def readFromFile(self, filename: str):
f = open(filename, \'r\')
c = file.readlines()
self.name = c[0]
for in range(1, len(c)):
self.addCourse(Course.fromCSV(c[i]))
f.close()
