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 trialThapelo Mokgwaphe
5,892 PointsNameError: name not found. I just don't understand the error
Help, spent hours trying to correct the error
class Student:
name = "Thapelo"
def praise(self):
return ("You're doing a great job, {}".format(name))
1 Answer
Brandon Evans
8,154 PointsHey Thapelo!
You're very close. Remember that when formatting within the class instance of Student
, that self
should not only be referenced as a parameter within the praise()
function, that self
must also be referenced within the formatting as well. Hopefully that makes sense.
Here is an example of what I mean:
class Student:
name = "Thapelo"
def praise(self):
return "Nice job, {}!".format(self.name)
student = Student()
print(student.praise())
great job :)
Thapelo Mokgwaphe
5,892 PointsThapelo Mokgwaphe
5,892 PointsThank you Brandon