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

Kyle Salisbury
seal-mask
.a{fill-rule:evenodd;}techdegree
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,363 Points

Your First Method

I'm not sure what else it is asking me to do. I've ran this code in workshop and it prints exactly what it asked me to print.

Also, I'm sure there is a simpler way of coding this (I think my code is a little long). Can someone help with that as well? Thanks!

first_class.py
class Student:
    name = "Kyle"

    def praise(self):
        print("You're doing a great job, {}".format(self))

Student.praise(Student.name)

2 Answers

Steven Parker
Steven Parker
230,995 Points

:warning: Be careful about testing a challenge in an external REPL or IDE.

If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.

In this case, the challenge doesn't ask you print anything. It does ask you to return the formatted string, and you haven't done that yet.

Also, it says you should return a message "which includes the name attribute".

Finally, you won't need to call the method yourself, the challenge will do that.

Kyle Salisbury
seal-mask
.a{fill-rule:evenodd;}techdegree
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,363 Points

class Student: name = "Kyle"

def praise(self):
    return "You're doing a great job, {}".format(self.name)

This worked now, thanks Steven.