I am receiving AttributeError: 'Test' object has no attribute 'a'. I don't understand what is wrong with the code. Please advise.
class Test():
def __int__(self):
self.a = 1
t = Test()
print(t.a)
I am receiving AttributeError: 'Test' object has no attribute 'a'. I don't understand what is wrong with the code. Please advise.
class Test():
def __int__(self):
self.a = 1
t = Test()
print(t.a)
It should be init (short for initialise), not int (integer):
class Test():
# here was the fault
def __init__(self):
self.a = 1
t = Test()
print(t.a)
# Outputs 1
You defined the wrong method