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__

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.

student.py
class Student:
def _init_ (self, name):
  self.name= 'munyaradzi'
def noun(self):
  return self.name

2 Answers

Hi there,

Great job getting this far!

After task 1, your code should look like this:

class Student:
  name= 'munyaradzi'

Then, for task 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.

class Student:
  name= 'munyaradzi'

  def __init__(self, name="your choice"):
    # Set self.name equal to the name argument.

Hope this helps,

Cheers

hie Robert ,thank you so much it worked. cheers

mine is not working. its saying object() takes no parameters

class Student: name = "Kennedy" def init(self, name = "Kennedy"): self.name = name

Likely an indentation problem. class Student: name = "Kennedy"

def init(self, name = "Kennedy"): self.name = name