Python Object-Oriented Python Instant Objects Your first method

superliminal
superliminal
30,205 Points

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

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.