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

mohan Abdul
PLUS
mohan Abdul
Courses Plus Student 1,453 Points

creating instance challenge task 2 step 2.

I am stuck on this challenge. i also tried:

class Student:
    name = "mohan"
    me = Student()
    print(me)```

```first_class.py
class Student:
    name = "mohan"
    me = name()
    print(me)

1 Answer

Steven Parker
Steven Parker
231,248 Points

It looks like you have these issues:

  • the task 2 code should be outside of the class (so not indented)
  • to create an instance you use the class ("Student()"), not the attribute ("name()")
  • to reference an attribute you put both the instance name and the attribute name with a period between
class Student:
    name = "mohan"

me = Student()
print(me.name)