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

Michael Kaminski
Michael Kaminski
1,419 Points

I keep getting an error when I try to make a class called Student and an instance called me. Please help!

The instructions state: Now, make an instance of your class named me. Then print() out the name attribute of your instance.

I make a class called Student and then put in name="me", and then when I print it, I get an error saying it couldn't find me. I don't get it. Can someone give me a hint please?

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

2 Answers

Scott Bailey
Scott Bailey
13,177 Points

The question is asking you to create an instance of the class Student - called "me"

me = Student()

This creates a new instance of Student called "me"

From there have a go at print the "name" of the new student (me)

Hi Michael,

It looks like it's asking you to create a class called Student, with your name as a string in the name attribute. After that, it wants you to create an instance of Student called

me = Student()

Then you can print with

print(me.name)