Reputation: 11
As you can see in this python code, I am trying to learn about class in python. But this code is showing an error.
arpi = stu("arpit", 26)
TypeError: stu() takes no arguments
class stu:
def __int__(self, name,age):
self.name= name
self.age=age
arpi = stu("arpit", 26)
print(arpi.name)
Upvotes: 0
Views: 82
Reputation: 21
your function in the class is wrong. It's meant to be __init__(...)
not __int__(...)
>>> class stu:
... def __init__(self, name, age):
... self.name=name
... self.age=age
...
>>> arpi=stu("arpit", 26)
>>> arpi.name
'arpit'
>>> arpi.age
26
>>>
Upvotes: 2