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

Andrew Bickham
Andrew Bickham
1,461 Points

def praise

i keep getting "You forgot the self argument in your praise method" which i don't quite understand

first_class.py
class Student:
    name = "andrew"

    def praise(self):
        y = "good job"
        x = "{} {}".format(y, self.name)
        if self.name == "andrew":
            return x 


teacher = Student()

teacher.praise()

2 Answers

Steven Parker
Steven Parker
231,275 Points

Your method currently returns the string only if the name is "andrew".

But it should always return the message, no matter what the name is set to!

Andrew Bickham
Andrew Bickham
1,461 Points

thank you guys, my apologies i miss read the question

Remove the if statement. If the checker changes the name your praise method returns None which may be the cause of failure. Could be something else. But it is a good idea to do just what the challenge asks and no more.