Решаю задачки на codeacademy на наследование классов.
Вроде, все верно, но сайт говорит: “Oops, try again. my_car does not appear to be an instance of ElectricCar”. В чем ошибка?
сlass Car(object):
condition = “new”
def __init__(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
def display_car(self):
return ‘This is a’ + ‘ ’ + self.color + ‘ ’ + self.model + ‘ ’ + ‘with’ + ‘ ’ + str(self.mpg) + ‘ ’ + ‘MPG.’
def drive_car(self):
self.condition = ‘used’
my_car = Car(“DeLorean”, “silver”, 88)
print my_car.condition
my_car.drive_car()
print my_car.condition
class ElectricCar(Car):
def __init__(self, battery_type, model, color, mpg):
self.battery_type = buttery_type
self.model = model
self.color = color
self.mpg = mpg
my_car = ElectricCar('moltensalt', ‘Ecar’, ‘red’, 88)