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

Daniel Mula Tarancón
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Daniel Mula Tarancón
Full Stack JavaScript Techdegree Graduate 37,873 Points

I am having problems creating the instance

I have to make an instance of my class named "me". Then print out the name attribute of my instance.

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

1 Answer

Dave Harker
PLUS
Dave Harker
Courses Plus Student 15,510 Points

Hi Daniel Mula Tarancón,

You're really close. The issue is the the second part of the challenge there where you need to:

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

You need to fix your indentation so you're not instantiating the class object inside the class, and also you'll need to add the print() function as per challenge requirements.

Something like:

# Nailed this part 
class Student:
    name = "Daniel"

# Fixed indentation, added required print function
me = Student()
print(me.name)

Really nice work, you almost had it. Keep pushing forward and having fun!
Dave :dizzy: