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 trialAizah Sadiq
2,435 PointsWhy is this code failing
Challenge task 2 of 2 and the error is it can't find 'Student'.My code is attached :)
class Student:
name = 'Aizah'
Student('me')
print(name)
4 Answers
Steven Parker
231,275 PointsThe code after the class should not be indented. Also, you may want to review the syntax for creating an instance and accessing attributes. Creating an instance will require the assignment operator ("_"), and accessing an attribute will use the membership operator (".").
UPDATE: - the (task 2) code after the class is still indented
- there is still no creation of the variable "me" and assignment with a new class instance
- there is still no reference to the class in the "print", and no membership operator
- plus now, the class name is being referred to as "Student_me" instead of "Student"
You might want to review the video, and take another look at the examples in it.
Aizah Sadiq
2,435 Pointsclass Student:
name = 'Aizah'
Student_me()
print(name)
it is still not running
Aizah Sadiq
2,435 Pointsok, thank you
Aizah Sadiq
2,435 PointsSorry to bother you but where am I going wrong now
class Student:
name = 'Aizah'
me = Student
print(Student.name)
Steven Parker
231,275 PointsSteven Parker
231,275 PointsAnother update: