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.

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,532 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,532 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'))