You need to construct the string in the
__str__
method if that is what you want it to look like.
Also you need to decide if
Student.course
is a list or a single item.
class Student(object):
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 "{} is enrolled in {}.".format(self.first_name, self.course)
def enroll(self, course):
self.course.append(course)
def main():
student = Student('John', 'Smith', 'L01234567', 'senior')
student.enroll('CSC225')
print(student)
main()