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

Using the "self" argument with methods

The challenge instructs me to use a method "praise" within the class "Student". There is also an attribute "name" within Student. The challenge is to use the praise method to print out a compliment that includes the "name" attribute but is passed the "self" argument. Any advice to help me out?

first_class.py
class Student:
    name = "James"
    def praise(self):
        print("It would be great if {} got some help learning this.".format(self))

    praise(name)

1 Answer

You are so close! In your code, in the praise function, you are using print. The code challenge says: "I need you to add a method name praise. The method should return a positive message about the student which includes the name attribute."

All you got to do is change your code to return instead of print. Hope this helps! :

like this,

class Student:
    name = "Your_name_here"

    def praise(self):
        return "You inspire me, {}".format(self.name)