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 trialKade Carlson
5,928 PointsNot 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
class Student:
name = "Kade"
def praise(self):
return "You're doing a great job, {}!".format(name)
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey 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!
Kade Carlson
5,928 PointsKade Carlson
5,928 PointsIt worked, thank you!