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 trialA Fletcher
7,158 PointsI cannot see what is wrong with my code
It appears I have used the correct syntax - any ideas?
class Student:
name = "Your Name"
def praise(self):
print("Great work, {}!".format(self))
return
A Fletcher
7,158 PointsThanks for your response. Turns out there is nothing wrong with the code but I had been asked to return a string and not print. Thank you
1 Answer
Cameron Childres
11,820 PointsHi A Fletcher,
Two things to note:
- The task wants a string returned, not printed
- The string needs to include the name attribute
You did a good job creating the method with the self argument. To access the name attribute you'll use self.name
All together it will look like this:
class Student:
name = "Your Name"
def praise(self):
return "Great work, {}!".format(self.name)
Hope this helps! Let me know if you have any questions.
A Fletcher
7,158 PointsSpot on - thank you!
Josh Stephens
13,529 PointsJosh Stephens
13,529 PointsWhat are the errors that you are seeing. Running this on my machine seems to work just fine