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

Exception: unorderable types: Student() > int() I am stuck with this kind of error mesage.

Tried several variations of the code (you hopefuly can see in attachment) but non of them works. Please help.

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

1 Answer

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Hey Artur Ferfecki

You have a few errors within this code. The one causing your current error is because of how you defined your feedback method.

In Python when defining what is called an instance method. The first parameter of that method HAS to be self.

In yours you have defined grade as the first parameter and self as the 2nd. If I ran this code on my own machine with my own test data, we can test what is happening.

I added a few print statements in feedback method.

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(grade, self): # 1st Error: TypeError: > not supported
        print('Grade: ', grade) # this is for testing, dont use in code challenge
        print('self: ', self) # this is for testing, dont use in code challenge
        if grade > 50:
            return self.praise # 2nd error: these are methods, dont forget parenthesis
        else:
            return self.reassurance # 2nd error: these are methods, dont forget parenthesis

if __name__ == '__main__':
    student = Student() # Create student instance
    student.feedback(60) # We have to pass a grade to this method.


# OUTPUT we would get with modified code.
#
# Grade:  <__main__.Student object at 0x00000230F402A208>
# self:  70

Now the other issue you will run into after you fix this is Exception: argument of type 'method' is not iterable. And that is because