Inheritance - "my_car does not appear to be an instance of ElectricCar"


#1



https://www.codecademy.com/courses/python-intermediate-en-egNXj/1/3?curriculum_id=4f89dab3d788890003000096#


Error:
my_car does not appear to be an instance of ElectricCar

(however, the code runs with no error in the interpreter)


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg

    def drive_car(self):
        self.condition = "used"

    def display_car(self):
        print "This is a %s %s with %s MPG."%(self.color, self.model, self.mpg)
        

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

my_car.drive_car()
print my_car.condition


class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        self.model = model
        self.color = color
        self.mpg   = mpg
        self.battery_type = battery_type
    
    my_car = ElectricCar("Ford", "black", 125, "molten salt")
    print my_car.condition

    my_car.drive_car()
    print my_car.condition

Thanks


#2

    my_car = ElectricCar("Ford", "black", 125, "molten salt")
    print my_car.condition

    my_car.drive_car()
    print my_car.condition

Indent them properly!

hint**


#3

Thanks! (damn indents)


#4

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