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

Andrei Oprescu
Andrei Oprescu
9,547 Points

can someone tell me what I am doing wrong?

I am on a question:

Great work!

Now, make an instance of your class named me.

Then print() out the name attribute of your instance.

And I currently have a code like this:

class Student: name = "Andrei"

me = Student() print(me.Student.(name))

Can someone tell me what I am missing out on?

Thanks

first_class.py
class Student:
    name = "Andrei"

me = Student()
print(me.Student.(name))

2 Answers

Hi there,

You just want to chain the property name onto the instance me using dot notation. You don't need to use the class name in your print code.

print(me.name)

Steve.

Andrei Oprescu
Andrei Oprescu
9,547 Points

Thanks! I thought I also had to include the class I a m getting the attribute from.

No, you don't. The instance you created includes all the information contained within the class definition.