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

Why can't "Well done, {}".format(name) be used?

how do I do this question

first_class.py
class Student:
    name = "mari"

    def praise(self):
        self.name
        return "Well done, {}".name

1 Answer

boi
boi
14,242 Points

Using "Well done, {}".format(name) will give you a "name" error, while using it inside a class, outside a class, it should be fine.

since your making use of a class Student in that case, an instance should be referenced to name.

class Student:
    name = "Mari"

>>> student = Student() 👈 #Created an instance of class Student

>>> student.name
"Mari"

self is an instance, if you need more clarification, hit me up again here.