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__

Dustin Wahba
Dustin Wahba
13,362 Points

what am i doing wrong?

class Student: name = 'Dustin' def init(self, name): self.name = name

student.py
class Student:
  name = 'Dustin'
  def __init__(self, name):
    self.name = name

2 Answers

Dan Johnson
Dan Johnson
40,533 Points

Your code will run fine but the challenge expects the name argument of __init__ to have a default value (It can be whatever you want).

Dustin Wahba
Dustin Wahba
13,362 Points

Thanks Dan. I'm new to the site and couldn't find where other people were asking questions. Then I figured out how to search the forum and found someone who was having a similar problem and was able to figure out that the initialization had to happen within the arguments list (or maybe its an argument tuple?). and was able to move on. but it was driving me crazy!! haha thanks again for your help and quick reply though!

Dustin Wahba
Dustin Wahba
13,362 Points

i think i might have answered my tuple question though, the arguments to a function cannot be a tuple because assignment is invalid within a tuple. Is this logic correct?

Dan Johnson
Dan Johnson
40,533 Points

Arguments to a function or method aren't necessarily a tuple, the parentheses in this case just list out the arguments (or lack of).

Passing in tuples would look like this:

zip((1,2,3), ('a','b','c'))