Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Instant Objects Your first method

Aiden Li
Aiden Li
10,406 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.

first_class.py
class Student:
    name = "Aiden"
    def praise(self):
        return('Well done, {}'.format(self))

Student.praise(Aiden)

1 Answer

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.