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 trial

Python Object-Oriented Python Instant Objects Method Interactivity

first class

((I'm stuck on this:))

Challenge Task 1 of 1 Alright, I need you make a new method named feedback. It should take an argument named grade. Methods take arguments just like functions do. You'll still need self in there, though.

If grade is above 50, return the result of the praise method. If it's 50 or below, return the reassurance method's result.

((When i put in my code:))

Bummer: Exception: feedback() takes 1 positional argument but 2 were given

first_class.py
class Student:
    name = "Caleb"

    def praise(self):
        return "You inspire me, {}".format(self.name)

    def reassurance(self):
        return "Chein up, {}. You'll get it next time!".format(self.name)

    def feedback(self):
        grade = 100
        if grade < 50:
            return self.praise
        elif grade >= 50:
            return self.reassurance

1 Answer

Hey Caleb, you got pretty close! 3 things to go over:

Rather than setting the grade variable in your feedback method, you need to provide it as an argument alongside self.

You need to include the parentheses to actually call your class methods e.g. self.praise()

You need to swap around your method calls. Right now the praise method is being called if the grade is under 50, and the reassurance method if the grade is over 50.

Hope this helps!

I tried this, but it says: Bummer: Didn't find the the praise message with a grade under 50.

class Student:
    name = "Caleb"

    def praise(self):
        return "You inspire me, {}".format(self.name)

    def reassurance(self):
        return "Chein up, {}. You'll get it next time!".format(self.name)

    def feedback(self, grade):
        grade = 100
        if 50 < grade:
            return self.praise()
        elif 50 >= grade:
            return self.reassurance()

Not sure I understood what you said.

You've got it, just remove line 11 and it will pass. You don't want to explicitly set the value of grade inside the method. The rest looks great!