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 trialAndrei Oprescu
9,547 Pointscan 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
class Student:
name = "Andrei"
me = Student()
print(me.Student.(name))
2 Answers
Steve Hunter
57,712 PointsHi 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
9,547 PointsThanks! I thought I also had to include the class I a m getting the attribute from.
Steve Hunter
57,712 PointsNo, you don't. The instance you created includes all the information contained within the class definition.