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

What am I doing wrong?

Hi! When I click "Check Work" I always get "Oh no! You forgot the 'self'....

What am I doing wrong? Or its a bug?

first_class.py
class Student:
    name = "Marcos"

    def praise(self):
        print(f"You are doing a great job, {self.name}!")

I tried this code in Workspaces and it works. Strange...

Myles Brathwaite
Myles Brathwaite
1,971 Points

I have a separate Question, why is the self when formating the return string

Myles Brathwaite self in python represents or points the instance which it was called. Python will replace self.name with 'instance_name'.name.

1 Answer

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,799 Points

You want to return the praise not print it. Replace your print with a return and it will pass.

Thank you, it worked:

def praise(self):
        return f"You are doing a great job, {self.name}!"