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

I'm stuck on this code challenge and not sure why my code is returning "try again"

Alright, I need you to make a new method named feedback. It should take self and an argument named grade. Methods take arguments just like functions do.

Inside the feedback method, if grade is above 50, return the result of the praise method. If it's 50 or below, return the reassurance method's result.

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

I tried this code without the int() and it told me the method was itterable

1 Answer

next time my friend. just post it as a class issue. because when i read your problem i immediately thought it was a classmethod problem. second

class Student:
    name = "Your Name"
    # grade = 49 # the grader did not like this extra property (I commented out)

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

the problem you have is that you shouldn't have a int. you don't need it. if you check here it works without it Randall Varasteh

so i tried to use the int() because when I run that into the challenge it gives me: Bummer: Exception: argument of type 'method' is not iterable i tested the code on my own computer and it works fine so I'm not sure why its not working on the challenge

hm. it might also be because of a fact that maybe its because it is your computer and it is able to handle a larger amount of code. or its able to process it better. or it may be that one has python3 the newest version of python and one has a older version. Randall Varasteh it also might be the fact that one computer believes that it should be done a different way and another believes its fine the way it is i presume.