Feb-24-2018, 04:32 AM
class student: def __init__(self, first_name, last_name, student_id, year): self.first_name = first_name self.last_name = last_name self.student_id = student_id self.year = year self.course = [] def __str__(self): return self.first_name, self.course def enroll(self, course): self.course = course def main(): file = student('John', 'Smith', 'L01234567', 'senior') print(file) file.enroll ('CSC225') main()so when I call enroll on 'CSC225' I want it to print “John is enrolled in CSC225.” But I cannot figure out what I am doing wrong. I just threw in the print statement to test it out but it is not working the way I thought it should. This is the latest error I have been getting when with what I have last tried to get it to work:
Error: line 22, in main
print(file)
builtins.TypeError: __str__ returned non-string (type tuple)