Python Object-Oriented Python Instant Objects Your first method

Aiden Li
Aiden Li
2,779 Points

The program returned 'couldn't find 'Student'' even though it was defined as a class earlier on... what am I doing wrong

I tried changing both the class definition and call line to lower case as well, returned the same message even though there wasn't a 'Student' anymore.
class Student:
    name = "Aiden"
    def praise(self):
        return('Well done, {}'.format(self))


1 Answer

Brandon White
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Aiden,

A few things. The reason Student could not be found is because you’re leaving off the (), when you try to call Student. So the interpreter doesn’t know that you’re trying to invoke the class Student.

To call it using the code you having written would require you changing the last line to Student().praise(). You don’t need to include your name, because your class definition doesn’t accept any parameters (you don’t have a constructor function currently).

That said, the challenge doesn’t require you to call the praise method. Take a look at the format method you’re calling on the return string. self only passes in the instance of the object to the praise method, in order to get the name from that you have to use dot notation to ask for it.

If you have trouble with that last part, let me know.