Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Emil Hejlesen
3,014 PointsWhy doesn't this work?
i just don't get i cause i can't find the error in this code
class Student:
name = "Your Name"
grade = 50
def praise(self):
return "You inspire me, {}".format(self.name)
def reassurance(self):
return "Chin up, {}. You'll get it next time!".format(self.name)
def feedback(self, grade):
if self.grade > 50:
self.praise()
else:
self.reassurance()
1 Answer

andren
28,538 PointsThere are two issues:
- You are not supposed to add
grade
as a class attribute, only as a parameter. That means that you should not define it at the top of the class, and not refer to it with theself
keyword. - You are asked to return the result of either the
praise
orreassurance
methods. You call those methods but you do not return their result.
If you fix those two issues like this:
class Student:
name = "Your Name"
# praise should not be defined as a class attribute
def praise(self):
return "You inspire me, {}".format(self.name)
def reassurance(self):
return "Chin up, {}. You'll get it next time!".format(self.name)
def feedback(self, grade):
if grade > 50: # Since grade is a parameter you don't use the self keyword
return self.praise() # Return the result of the method
else:
return self.reassurance() # Return the result of the method
Then your code will pass.
Emil Hejlesen
3,014 PointsEmil Hejlesen
3,014 Pointshey thx for the help i have tried this and it didn't work it said there was no grade in the class but thx for the help