Unable to get past step 8 in Classes Exercise! Please Help. Link to the exercise: https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-classes/lessons/data-types/exercises/review

https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-classes/lessons/data-types/exercises/review

Unable to get past step 8 in the exercise at the end of the lesson for classes, lesson 1. I am getting an error message saying ‘object of type ‘NoneType’ has no len()’

Can someone point me in the right direction, on where I am going wrong with the above code?

This is not how you add a grade:
image

You are trying to set Pieter’s .grades attribute to pieter.add_grade(grd) rather than just using the .add_grade method to add the grade to the .grades attribute (which is an empty list).

Because you are changing pieter.grades to a different type, your code is failing this test in _test.py:
image

Thank you for the quick reply.

However, I tried with the following line of code before I tried the one given above, but it is also showing a failure message:

Ah, I see now that you also have a line here that will return an error:

image

Codecademy’s _test.py checks on line 32 if pieter.grades[0] is type(Grade) (see screenshot in my last response).

When you append grade.score instead of grade, you are not appending an object of type(Grade).

Hey, Thanks. Changing grade.score to grade for the time being did the trick. But it returned undesirable output. So, once I changed it back to grade.score, it stored the integer value for the grade.

Not sure what you mean by “undesirable output.” The whole point was to append a Grade object (not just the score integer) to the .grades attribute. That way, you can call the is_passing method on each grade…

I am a bit confused now. Is this not the right logic of what was supposed to be achieved? Can you tell me what was intended of the code, if otherwise?

The problem is that if you store just an integer in pieter.grades as you said you did here…

…then you can’t check if Pieter’s grades are passing using is_passing.

You should be able to say

print(pieter.grades[0].is_passing())

Otherwise, you will have to store each grade for each student as a separate variable in order to check them.

Got it. Will make the list score the Grade object instead of the integer value of grade.score for is_passing() argument.

Thank you for clarifying it.