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 Method Interactivity

Class methods

I am so confused as to why this is not working. I try it on a text editor and it works perfectly fine. Can someone please direct me to another explanation of class's.

first_class.py
class Student:
    name = "Your Name"

    def praise(self):
        return "You inspire me, {}".format(self.name)

    def reassurance(self):
        return "Chin up, {}. You'll get it next time!".format(self.name)

    def feedback(self, grade):
        if grade > 50:
            return self.praise()

adrian = Student()
print(adrian.feedback(55))

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Adrian Diaz! It looks like you're doing really well and you're almost there. You just haven't quite finished the assignment the task set out for you. The task asks you to return self.praise() if the grade was greater than 50, which you did just fine. However, if it's not greater than 50 it should return self.reassurance(). In short, you're missing an else statement in your feedback() method.

Hope this helps! :sparkles:

edited for additional information: Also, you will not need to create an instance of Student yourself or print anything for the purposes of this challenge. :smiley:

Thanks!