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 trialNancy Melucci
Courses Plus Student 36,143 PointsWhat is an "instance attribute"?
Can anyone give me a hint?
I know what an instance is, and I know what an attribute is. I am not familiar with this term and I can't get past this step without being able to interpret it.
Thanks.
class Student:
name = "Nancy"
def praise(self):
return "You didn't screw up as badly as usual, {}".format(self)
Nancy = Student()
Nancy.praise()
5 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsself.name is correct. that is the argument for format. then you just need to delete the last two lines because the autograder will take care of that stuff. ...[submits your code]... actually you don't even have to delete those lines, i just passed it simply by passing in self.name as the argument to format.
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou don't need to create an instance or call the method, the autograder does that, and apart from that you are very close, it's just your argument to format is incomplete....use dot notation to access the required attribute of self that goes in the {}.
if our class was bank accounts, each instance would be an individual account. a class attribute might be the routing number, common to all accounts, while an instance attribute might be the individual account numbers, each account having a different and unique number.
Nancy Melucci
Courses Plus Student 36,143 PointsI have to confess that I still don't understand how I need to change this code. Are you saying remove everything except the praise method itself? Where exactly do I add the code to access "name"?
I feel dumb. But I really don't know where to add the access for the attribute. I tried using self.name (I've seen this online) but I keep failing the challenge. What the instructor does with .format is somewhat different (there's a boolean test) so I just can't use his template to make this simply return a print message.
Sorry. I wouldn't be asking if I hadn't tried many things to make this work.
Miguel Sánchez
10,365 PointsPretty close. You only need to specify the .name in the format method.
class Student: name = "Miguel" def praise(self): return "Have fun, {}".format(self.name)