9. Inheritance


Did I miss something?Why this code is not working? Thank you


Oops, try again. my_car does not appear to be an instance of ElectricCar.

class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg
    def display_car(self):
        print "This is a %s %s with %s MPG." %(self.color, self.model, self.mpg)
    def drive_car(self):
        self.condition = "used"

my_car = Car("DeLorean", "silver", 88)
print my_car.condition
print my_car.model
print my_car.color
print my_car.mpg
print my_car.condition

class ElectricCar(Car):
    def __init__(self):
        Car.__init__(self, model, color, mpg)
        self.battery_type = battery_type

my_car = ElectricCar("Volks", "Blue", 87, "molten salt")


All the necessary parameters are missing.


Ok I got it now. Thank you


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.