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

I am trying to add a method named "praise" a class named "Student" and return a positive message but its not working.

I feel like I am doing everything this challenge is asking me to do, but I can't seem to quite get it done the way I am suppose to and I don't know what the problem is. Everytime I think I got it down pack after doing tons of research about classes and methods in python I still can't seem to quite understand it very well. It gives me this message "Didn't find the name in the praise message. Be sure to use the instance attribute! " Someone please help! this is my code.

class Student:
    name = "Your Name"

    def praise(self):
        return " Your doing great " + name
first_class.py
class Student:
    name = "Your Name"

    def praise(self):
        return  " Your doing great " + name

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

You are so close! As written, the variable name is not defined within the method. To get to the value of the attribute attached to the instance, use self.name.

Post back if you need more help. Good Luck!!