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

Andras Andras
Andras Andras
7,941 Points

Python First Class 2.2

Hello,

I cannot get along with this task. Can anyone help me?

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

2 Answers

The challenge instructs you to return the result of the praise method if the grade is greater than 50 or the result of the reassurance method if the grade is lower than 50. In your code, you are not calling the respective methods praise and reassurance.

You simply need to include the parentheses after the self.praise and self.reassurance in your return statements.

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

By the way, make sure to remove the grade = 50 statement which you added in your code before you submit. I think that added code will cause the challenge to fail even after you make the corrections to the return statements.

Hi there!

You're really close. Unfortunately there's a little bit of a trap in this challenge. you have to make a method that takes an argument called grade, which you got spot on:

def feedback(self, grade):

But the class also has a variable called grade. When you check self.grade, you're actually checking the class variable named grade, not the grade argument passed into the feedback method, and the internal self.grade is always 50. Just a reminder:

class Test:

    name = "bob"

    def internal(self, name):
        print(self.name)
        print(name)

names = Test()
names.internal("Jeff")

Will print:

bob
jeff

Secondly you're returning the class methods, not their return values - just call them to get their return values, and return the value you get back :)

Actually, the challenge does not even include a grade field. I think the OP simply was using it as a test to determine why his/her code wasn't working.