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 trialMUZ140515 Herbert Chirwa
2,589 Pointsdid l put _init_ on the right position coz code won,t pass
help code won't pass
class Student():
name = 'Herbert'
def _init_(self.name ='Herbert'):
self.name = 'Herbert'
def noun(self):
return self.name
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsThere are a few errors in the code: __init__()
needs double underscores, the first parameter to __init__()
needs to be self
(fixed by changing Dot to Comma), and need to assign passed in name
parameter to self.name
attribute.
class Student():
name = 'Herbert'
def __init__(self, name='Herbert'): #<-- Double underscores, change Dot to Comma
self.name = name #<-- assign passed in name
def noun(self):
return self.name