Python Forum
Class Error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Class Error (/thread-5313.html)



Class Error - OmarSinno - Sep-28-2017

class Students:
    def _init_(self,name,age,grade):
        self.name = name
        self.age = age
        self.grade = grade

student1 = Students("Bob", 12, "7th")
print(student1.name)
I only want the student's name to get printed yet it is not working :
Error:
File "C:\Users\ohh05\Desktop\tet3.py", line 7, in <module> student1 = Students("Bob", 12, "7th") TypeError: object() takes no parameters



RE: Class Error - Mekire - Sep-28-2017

You need double underscores not single,
Change this def _init_ to this def __init__.