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 trialMark Nembhard
1,387 PointsNot sure how to trigger the right result calling a method with a class
i see what needs to be done but i cannot supply the correct code to provide the result if a student goes over 50 in their test or equal and/or below 50. I am getting confused on the syntax and the use of "self". I understand it is an instance of a class or method but i am not quite getting the syntax
class Student:
name = "Mark"
def feedback(self,grade):
self.grade = 51
if self.grade > 50:
Student.praise
def praise(self):
return "You inspire me, {}".format(self.name)
elseif self.grade<= 50
Student.reassurance
def reassurance(self):
return "Chin up, {}. You'll get it next time!".format(self.name)
1 Answer
Steven Parker
231,269 PointsHere's some hints:
- don't change the originally provided code, including the indentation
- add your new code after the provided code, don't mix it in between
- code in a class should not reference the class by name, so use "
self.
" instead of "Student.
" - when calling a method, the name should be followed by parentheses (even if no arguments are passed)