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 Your first method

error about self

This class should look familiar!

I need you to add a method name praise. The method should return a positive message about the student which includes the name attribute. As an example, it could say "You're doing a great job, Jacinta!" or "I really like your hair today, Michael!".

Feel free to change the name attribute to your own name, too!

first_class.py
class Student:
    name = "Your"
    def praise(self):
        print("he {} is awesome".format(self))

This is the error i am getting. Can anyone tell me whats wrong with this Oh no! You forgot the self argument in your praise method

3 Answers

Jamie Tsang
Jamie Tsang
2,749 Points

This is what I did:

class Student: name = "Your Name"

def praise(self):
    return "You're doing a great job " + self.name
Steven Parker
Steven Parker
231,269 Points

The instructions say, "The method should return a positive message about the student which includes the name attribute."

So you still need to "return" the result. And you won't need to "print" anything.

Also, be sure to include the name in the returned string.

UPDATE: I just solved this. We pass the self instance as a parameter, while excluding name. I still am wishfully hoping that Treehouse can provide better automated error feedback :) Because I do get stuck once in a while. (They do great work, though) :)

original post

I have the same aforementioned error. Like Ram Ranga, the debugging message ("You forgot the self argument in your praise method") isn't specific enough for me to troubleshoot, unfortunately. However, in the Python command line I don't have an error when I run this code:

class Student:
    def __init__(self):  # I didn't formally learn this but it's pretty straightforward.
        print("in init")

    def praise(self, name):
        return "way to go, {}!".format(name)

#### instantiating the class: these commands work
# me = Student()
# z = me.praise("Bob")

Thanks to anyone who can help!