i´m having an attribute error on my code when i try to encapsulate a variable and i cant see why.
class Car():
def __init__(self):
self.__doors=4
self.sizeChasis=250
self.colorChasis=120
self.running=False
def start(self,letsgo):
self.running=letsgo
if(self.running):
return "Car is on"
else:
return "Car is off"
def state(self):
print("The car has ", self.__doors, "doors. And ", self.sizeChasis, "and ", self.colorChasis)
myCar=Car()
print("A: ",myCar.sizeChasis)
print("B: ", myCar.__doors, "doors")
print(myCar.start(True))
myCar.state()
And here is the error:
rint("B: ", myCar.__doors, "doors")
AttributeError: 'Car' object has no attribute '__doors'
Probably is an easy question but i cant see the solution.
Thanks