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

Kade Carlson
Kade Carlson
5,928 Points

Not sure why it's telling me I'm not using the name attribute

It gives me this error when I run my code: Didn't find the name in the praise message. Be sure to use the instance attribute!

Not sure why it's doing that

first_class.py
class Student:
    name = "Kade"

    def praise(self):
        return "You're doing a great job, {}!".format(name)

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Kade,

The error is giving you a very strong clue... you are not using the instance attribute to access the name variable, which is outside of the method. Because the return is inside the method, it can't find the name value as it's outside. So, to get to the name you access it with the instance passed into the method (here you called it self). So instead of .format(name) ... you need .format(self.name).

Hope that helps. :)

Keep Coding! :dizzy: