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 (retired) Objects __init__

What's wrong with this code? Why isn't it checking?

What should be the "right code"?

This is "Challenge Task 1 of 2", in "Object-Oriented Python", in the Learn Python track.

student.py
class Student:
    name = "name"

    __init__(self, name="name1"):
            self.name = name

I've also tried this code

student.py
class Student:
    #no name = "name"
    __init__(self, name="name1"):
            self.name = name

1 Answer

Steven Parker
Steven Parker
229,732 Points

:point_right: It looks like you're on task 2.

For task 1, all you need are the first 2 lines.

For task 2, you're missing the keyword "def" before your __init__ function.

Yup.