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 trialMarcos Lisboa
8,117 PointsWhat am I doing wrong?
Hi! When I click "Check Work" I always get "Oh no! You forgot the 'self'....
What am I doing wrong? Or its a bug?
class Student:
name = "Marcos"
def praise(self):
print(f"You are doing a great job, {self.name}!")
Myles Brathwaite
1,971 PointsI have a separate Question, why is the self when formating the return string
Marcos Lisboa
8,117 PointsMyles Brathwaite self in python represents or points the instance which it was called. Python will replace self.name with 'instance_name'.name.
1 Answer
Mark Sebeck
Treehouse Moderator 38,304 PointsYou want to return the praise not print it. Replace your print with a return and it will pass.
Marcos Lisboa
8,117 PointsThank you, it worked:
def praise(self):
return f"You are doing a great job, {self.name}!"
Marcos Lisboa
8,117 PointsMarcos Lisboa
8,117 PointsI tried this code in Workspaces and it works. Strange...