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 trialRuslan Pilipyuk
857 PointsPlease help me with that task, check my code because idk what im doing wrong and why it shows that name is not defined?
m
class Student:
name = "Ruslan"
def praise(self):
return ("I really like your hair today, {}!".format(name))
1 Answer
Jonathan Perdomo
Python Development Techdegree Student 11,506 PointsThe problem is that name inside the method isn't defined. I had the same problem try self.name instead. Remember that the variable "Ruslan" is set to name inside the class Students. In other words to access your name it would be Student.name
Let Me know if this helps!
Ruslan Pilipyuk
857 PointsRuslan Pilipyuk
857 PointsHello, thanks for your answer. I fixed that but still have error:
class Student: name = "Ruslan" def praise(self): print("I really like your hair today, {}".format(self.name)
This class should look familiar!
First, I need you to add a method named praise to the Student class. It should take the self argument. Then, inside the praise method, return a positive message about the student using the name attribute.
As an example, it could say "You're doing a great job, Jacinta!" or "I really like your hair today, Michael!".
Feel free to change the name attribute to your own name, too!
Bummer: Try again!