Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,347 Points__init__ question
The question states: Our Student class is coming along nicely! I'd like to be able to set the name attribute at the same time that I create an instance. Can you add the code for doing that? Remember, you'll need to override the init method.
I'm stuck on how to do this. I tried googling how to override the init method and the sample code below was something close to what other people were saying in stackoverflow but obviously this is not correct.
class Student:
name = "Your Name"
def __init__(self, name=None, **kwargs):
super(Student,self).__init__()
self["name"]=name
for key, value in kwargs.items()
setattr(self,key,value)
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()
return self.reassurance()
8 Answers

Kent Åsvang
18,822 PointsOkay, so you are pretty close, I have added some comments that I hope will help you understand what is going on:
""" You don't have to initiate name with a value, the argument alone is enough """
def __init__(self, name=None, **kwargs):
""" super() - calls methods on the parent class, and is not necessary in this challenge."""
super(Student,self).__init__()
"""this line is fine, although I prefer dot-notation myself. 'self.name'
self["name"]=name
""" This one is also correct, just remember to put the colon after 'items():'"""
for key, value in kwargs.items()
setattr(self,key,value)
Here is my solution :
def __init__ (self, name, **kwargs):
self.name = name
for key, value in kwargs.items():
setattr(self, key, value)
Hope this was helpful.

Mercedes Aker
6,544 PointsThis I have also tried but it continues to say, "Try again!"

Tobert Nasibu Amulani
8,423 Pointsstill its not working out

goodness mate
93 Pointsclass Student: name = "Your Name"
def __init__(self, grade):
if grade>50:
return self.praise
else:
return self.reassuran

Joseph Doma
3,055 Pointsplease help me on the int thing

CHO Ming TSENG
14,219 Pointsclass Student: def init(self,name): self.name=name

Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,347 PointsWell that's annoying.
My first attempt had everything you had, but I just forgot the ":" sign after the for statement.
Thanks!

Kent Åsvang
18,822 PointsIt's very typical to forget small stuff like that. I would recommend using pycharm, or a text-editor on the side while walking through the tracks here on treehouse. That way you can get used to the error-messages and to find bugs like this in your code

Michael Ma
4,294 Pointsclass Student: def init(self, name): self.name = 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, grade):
if grade > 50:
return self.praise()
return self.reassurance()

pierreilyamukuru
9,831 Pointsclass Student: name = "Pierre" def init (self, name, **kwargs): self.name = name for key, value in kwargs.items(): setattr(self, key, value)
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()
return self.reassurance()
Godfrey Chamunorwa
5,505 PointsGodfrey Chamunorwa
5,505 Pointsyou remove the super class its not necessary and after that line its self.name = name put the colon : after the items(): then you will get it write