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 trialMohammad Alawad
1,877 PointsChallenge Task 2 of 2 make an instance of your class named me. Then print() out the name attribute .Does not work
I really don't understand why this is not working, I am fed up with this! Please anyone can check this example it is the second part of the first challenge in the object oriented course/Python :
Challenge Task 2 of 2
Great work! Now, make an instance of your class named me. Then print() out the name attribute of your instance.
Class Student:
name = "something"
me = Student
print(me.name)
4 Answers
Ryan Sands
4,543 Pointsactually it should be......
class Student:
name = "something"
me = Student()
print(me.name)
when making an instance of a class you must add those parentheses after so it can be an instance, otherwise its not. this passed for me! Good luck, Keep on coding!
[MOD: added ```python formatting -cf]
Abubakar Gataev
2,226 PointsWhy did you use Student()?
Jack Lee
255 PointsHi, This is my code: class Student: name = 'Jack' me = Student print(me.name)
But...., I still cannot get the right output. Can u all tell me why?
luther wardle
Full Stack JavaScript Techdegree Student 18,029 PointsThis worked for me, I had the same code but forgot not to indent the code that's creating an instance of the class lol, so thank you!
Andrei Cordis
Courses Plus Student 4,442 PointsWhy indentation is not necessary in the last line (the print line) ?
goodness mate
93 Pointsyes, it works
cameth tanashe
4,260 Pointsit does not work bro
cameth tanashe
4,260 Pointsoh sorry it works
Nate Meyer
3,887 PointsNate Meyer
3,887 Pointsclass
instead ofClass
.