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

Richard Cairns
Richard Cairns
1,736 Points

first_class.py - I don't understand why this code isn't working.

Hi,

The error message I get is " Bummer! Didn't find the the praise message with a grade over 50."

I assume this means the calling code is setting the variable 'grade' to a value over 50 and then passing it to the feedback()

Feedback() has a simple if statement in it, that I've stared at for ages and can't see why it wouldn't return the correct string. Can anyone see what I'm doing wrong?

first_class.py
class Student:
    name = "Rich"
    grade = 0 #I'm assuming that the calling code will set this variable as part of the tests

    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 self.grade > 50:
            return self.praise()
        else:
            return self.reassurance()

1 Answer

Richard Cairns
Richard Cairns
1,736 Points

Never mind - I restarted the assessment from scratch, and got it the second time :)