Dec-10-2021, 03:08 PM
Hi, I am learning Python object oriented programming through this Youtube video. I am following along with his code. However, I am getting a "NameError" where I cannot pin-point where my error is in my code. I triple checked word-for-word of my code with the Youtuber's code and it matches up, but I am not sure why I am getting an error and he is not. Any help or suggestions would be greatly appreciated. Thanks!
class Student:
def __init__(self, name, age, grade):
self.name = name
self.age = age
self.grade = grade
def get_grade(self):
return self.grade
class Course:
def __init__(self, name, max_students):
self.name = name
self.max_students = max_students
self.students = []
def add_student(self, student):
if len(self.students) < self.max_students:
self.students.append(student)
return True
return False
def get_average_grade(self):
pass
s1 = Student("Tim", 19, 95)
s2 = Student("Bill", 19, 75)
s3 = student("Jill", 19, 65)
course = Course("science", 2)
course.add_student(s1)
course.add_student(s2)
print(course.students)
