Tinotenda Mangarai3,093 Points
What is wrong with my code. Someone help please. Been stuck for too long
Challenge Task 2 of 2 make an instance of your class named me. Then print() out the name attribute. Its not working
class Student: name = "Tino" me = Student() print(me.name)
Fred Gablick2,434 Points
You're thinking of this as a function instead of an object class. You need to define the object outside of the class. This is quick and dirty, but I think you'll see it:
>>> class Student: ... pass ... >>> me = Student() >>> me.nickname = "Bonehead" >>> print(me.nickname) Bonehead
You can use an init function inside the class to define your attributes, but you still want to define the object outside of the class.
>>> class Student: ... def __init__(self, name): ... self.name = name ... >>> me = Student("Bonehead") >>> print(me.name) Bonehead >>>
I hope that helps.