Man, I breezed through all of Python up until this point, and this is just an insane roadblock that I’m not getting through at all ;(
Anyway, I’m having trouble using the is_passing() method. Here is my code:
class Student:
def __init__(self, name, year):
self.name = name
self.year = year
self.grades = []
def add_grade(self, grade):
if type(grade) == Grade:
self.grades.append(grade)
class Grade:
minimum_passing = 65
def __init__(self, score):
self.score = score
def is_passing(self):
if self.score >= Grade.minimum_passing:
return True
else:
return False
roger = Student("Roger van der Weyden", 10)
sandro = Student("Sandro Botticelli", 12)
pieter = Student("Pieter Bruegel the Elder", 8)
pieter.add_grade(Grade(100))
x = Grade(70)
print(x.is_passing())
pieter.grade.is_passing()
When I do that, like you suggested, I get an attribute error:
AttributeError: 'Student' object has no attribute 'grade'
Any ideas? x.is_passing works fine.