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 __init__

Sabine Lazuhina
Sabine Lazuhina
2,334 Points

Exception: __init__() missing 1 required positional argument: 'grade'

I think I am doing everything correctly but somehow it says I am still missing positional argument "grade" ..

first_class.py
class Student():
    def __init__(self, name, grade):
        self.name = "Sabine"
        self.grade = int

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

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

    def feedback(self, grade):
        return "your grade is {}".format.randint(self.grade)
        if grade > 50:
            return self.praise(),
        else:
            return self.reassurance()

1 Answer

Steven Parker
Steven Parker
229,771 Points

In a sense, it's the challenge that's missing something. You added "grade" as a required argument for creating the "Student" class. But this was not part of the instructions, and when the challenge tests the code, it's not supplying that argument.

The only required argument should be "name". Then in task 2 you add code to handle optional arguments.