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 trialKarol Gutkowski
8,662 PointsHow to call attribute of a class in a method inside that same class
I feel like this exercise is easy but i overthink something here.
class Student:
name = "Your Name"
def praise:
print('Good job {}' .format(self.name))
1 Answer
Steven Parker
231,275 PointsSergio is mostly right, but the space doesn't actually cause any problem. It is a bit unconventional to put one there, though.
Also, in case that last suggestion wasn't clear:
- the function needs to "return" the formatted string
- you won't need to "print" anything
sergio alvarez
15,205 Pointssergio alvarez
15,205 PointsHi Karol, Python is picky, A couple of things you were missing
This should work
class Student: name = "Your Name" def praise(self): return ('Good job {}'.format(self.name))