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

Frances Angulo
Frances Angulo
5,311 Points

Student class

This code runs in the workspace but just doesnโ€™t work here, what am I missing??

first_class.py
class Student: 
    name = "Frances" 

me = Student()
    print(Student.name) 

2 Answers

Steven Parker
Steven Parker
231,248 Points

You've created an instance named "me" but the "print" is attempting to access the class "Student" directly. The name attribute of your instance would be "me.name".

Also, the "print" statement should not be indented.

Frances Angulo
Frances Angulo
5,311 Points

Ah - I wish the errors were more expressive or we had some sort of output that demonstrated why I was getting the right result but via the wrong class method. woof.

Steven Parker
Steven Parker
231,248 Points

Actually, if you had only the first issue, the error message given would have been much more helpful:
Bummer: Be sure to use me.name to print the attribute!