Could anyone help with my understanding, please? I don't understand what is happening with this line or why it works : course_running.add_student(self)
.
I thought this was an OOP concept but could anyone help make this clearer?
class Student:
def __init__(self, name, student_number):
self.name = name
self.student_number = student_number
self.classes = []
def enrol(self, course_running):
self.classes.append(course_running)
course_running.add_student(self)
class CourseRunning:
def __init__(self, course, year):
self.course = course
self.year = year
self.students = []
def add_student(self, student):
self.students.append(student)