CODE:
class student:
def _init_(self,i,j):
self.i=i
self.j=j
def info(self):
print(self.i,self.j)
leelasai=student(24,'cse')
leelasai.info()
Issue: When i executed my code it shows type error. Please resolve it.
CodePudding user response:
The name of the constructor function is incorrect.
Instead of _init_
, it should be __init__
(double undescores before and after init).
CodePudding user response:
I'm curious, normally python helps out with more than the info type error and also shows the line of the error. With this information, you should normally get a pretty good hint on what's wrong.
Also, adding such information, like the full error message for example and other essential information, is a huge help for people answering your questions and therefor makes it easier to answer questions. Since you are new, this may help you with questions in the future.