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

I really don't understand 'self'

I'm not getting any useful error, it just says 'bummer, try again' and I don't know what I'm doing wrong.

(For those in charge of course content, please rework this section (self) and probably also the one before it (dicts). The videos do not adequately explain what's happening, and the challenges ask for things the videos didn't cover. I should not be having to ask the community for help on every single challenge, and the fact that I am both slows down my learning and points to insufficiency in the material.)

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

    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 is > 50: 
            return praise(self) 
        elif grade is <= 50: 
            return reassurance(self) 

Update: I've rewatched the video at least 3 times and reworked the code in every permutation I can think of. I have no idea why it's not working. (I'm seriously about to quit this course, these videos do not adequately prepare you for the code challenges. Add more chances in the video for the student to try and code, then explain the correct answer. Make the errors actually useful. Add hints after 5 challenge attempts or something. Being stuck on one question for literal hours because the video didn't properly teach me how to code this, and having to wait and rely on community posts is infuriating.)

```class Student: name = "Your Name" grade = 79

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 praise(self) 
    elif self.grade <= 50: 
        return reassurance(self) ```

2 Answers

In the feedback method, you need to call the instance methods praise() or reassurance(), this is done by writing self.praise() and self.reassurance()

Methods are always called with this syntax <instance name>. <class method name>()

Readability note: The ... elif ... statement adds a redundant test, a simple else: does the job.

Almost there! The method feedback takes two arguments self and grade so instead of using a "." you should write feedback(self, grade)

grade is not an attribute of the class Student, it is the second argument of the method feedback()

Thank you for your quick answer! That makes sense, that I'm passing two arguments. Unfortunately I'm still getting a 'bummer, try again' error :(