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

Benjamin Parker
Benjamin Parker
1,752 Points

I don't understand what this code challenge wants me to do

CODING CHALLENGE PROMPT


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!


I'm not sure what this challenge is asking me to do exactly. I tried returning a string with the name attribute formatted in and concatenating the attribute as well. Any help would be appreciated. Also would help to know if my code is faulty or why the code it is looking for is better.

first_class.py
class Student:
    name = "Ben"
    def praise:
        return "YOU are doing great {}".format(name)
Benjamin Parker
Benjamin Parker
1,752 Points

DARN I'm so silly. I forgot to use parenthesis+self parameter....

But it still doesn't work...

Benjamin Parker
Benjamin Parker
1,752 Points

It keeps saying name is not defined... but it is isn't it?

1 Answer

Benjamin Parker
Benjamin Parker
1,752 Points

I figured it out...

I needed to use self.name as the attribute not name.