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 Instant Objects Your first class

challenge task 2 of 2: why isn't this working?

Python Object-Oriented Python challenge task 2 of 2:

class Student:
    self.name = 'John'
    self.name = 'me'
    print(self.name)
first_class.py
class Student:
    self.name = 'John'
    self.name = 'me'
    print(self.name)

Thank you Behar!

No problem John. You can mark the question as "Solved" by sellecting a "Best answer"

1 Answer

Hey John! You are slightly off track here. You dont need the self anywhere in this challenge. First of all the challenge tells you to make an attribute "name" and set it to your name. Youve done that correctly aside from the fact that you dont need a self. Secondly it wants you to make an instance of the Student class and assign it to the variable me. You have assigned an invalid variable self.name to the string "me"? Lastly it wants you to print the name attribute of the instance me. And this should be unindented as its not a part of the class. This was kinda hard to explain tho, so it might be easier to just see the code.

class Student:
    name = "Lucas"
me = Student()
print(me.name)

Hope this helps, please feel free to comment if you need more assistance!