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__

omg '-' where is wrong? I don't know DD:

Challenge Task 2 of 2

Override init in Student. Give init a name keyword argument with a default value of your choice. Set self.name equal to the name argument.

Bummer! object() takes no parameters

student.py
class Student:
    name = 'alex'

def __init__(self, name= "bacon"): 
    self.name = name

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Ok one more time. A method goes inside a class. It's a function specifically designated to be run on an object of that class. Fix your indentation again, and it passes :smiley:

HAHAHAHA beginners... thanks again :D

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Alex Galhardo well I'm no expert, I promise. But the fact that you fixed it without copy/pasting the answer is great. There is no better way to learn to code than to break your code, and then fix it :smiley: