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.

Python Object-Oriented Python Instant Objects Method Interactivity

Jack Cummins
Jack Cummins
17,417 Points

I cannot figure out why my code is wrong

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.

first_class.py
class Student:
    name = "Your Name"

    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):
        if grade > 50:
            return praise()
        else:
            return reasurance()

5 Answers

Steven Parker
Steven Parker
216,135 Points

The instructions say, " I need you make a new method named feedback. It should take an argument named grade."

But the function shown here doesn't take any argument (other than the implicit "self").

Also remember to use the "self." prefix when calling instance methods from within the class, and be careful about spelling!

Jack Cummins
Jack Cummins
17,417 Points

I used your reccomendation and it did not work. Would you please show me the code. I will make sure to take in and absorb the code as well as I can.

Steven Parker
Steven Parker
216,135 Points

Show the code you have now with the argument and the "self." prefixes added and the spelling fixed and I'll take another look.

Jack Cummins
Jack Cummins
17,417 Points
class Student:
    name = "Your Name"

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

    def reassurance(self, grade):
        return "Chin up, {}. You'll get it next time!".format(self.name)
Steven Parker
Steven Parker
216,135 Points

You've gone way off-track here, and were closer the first time.

The instructions are to "make a new method named feedback". You won't need to make any changes to the methods that are already there.

Jack Cummins
Jack Cummins
17,417 Points
class Student:
    name = "Your Name"

    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:
            return praise()
        else:
            return reasurance()
Steven Parker
Steven Parker
216,135 Points

So that's got the parameter added, but you still need to add the "self." prefixes to the method calls and fix the spelling.

Jack Cummins
Jack Cummins
17,417 Points

I don't get it. Where am I supposed to put the self.prefixes method? I know that this is a dumb question, but I really do not get what this code challenge was asking me to do. Would you please help me?

Sorrry for my troubles, Jack

Steven Parker
Steven Parker
216,135 Points

When you call an internal method, like "return praise()", add the prefix to the method name: "return self.praise()".

Jack Cummins
Jack Cummins
17,417 Points
class Student:
    name = "Your Name"

    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:
            return self.praise()
        else:
            return self.reasurance()

This code doesn't pass.

Steven Parker
Steven Parker
216,135 Points

You still need to fix the spelling.

Jack Cummins
Jack Cummins
17,417 Points

Thank YOU!!!!!!!!!!!!!!!!!

There you go!

def feedback(self, grade): if grade > 50: return self.praise() else: return self.reassurance()