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 trialKrishnan Sampath
Courses Plus Student 1,115 PointsI have doubt in Challenge Task
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!
class Student:
name = "Your Name"
def praise(self):
print("You're doing a great job, Jacinta!",self.name)
obj=Student()
obj.praise()
1 Answer
volhaka
9,875 PointsThere are several mistakes in your code.
method should return message, not print message.
Your message is not correct. You should use self.name as a part of message instead of Jacinta . There are several ways to do that:
f-string
f"You're doing a great job, {self.name}!"
or format
"You're doing a great job, {}!".format(self.name)
Krishnan Sampath
Courses Plus Student 1,115 PointsKrishnan Sampath
Courses Plus Student 1,115 PointsI am getting the below error message
Oh no! You forgot the
self
argument in yourpraise
methodPlease let me know what is wrong in the above code