9.Inheritance can't figure out what is wrong



Getting following error:
Oops, try again. my_car does not appear to be an instance of ElectricCar.


Traceback (most recent call last):
File "python", line 26, in
TypeError: init() takes exactly 4 arguments (5 given)

class 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 %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.condition

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

my_car = ElectricCar("Honda", "Blue", 32, "molten salt")


Hi that line

def __int__(self, model, color, mpg, battery_type):

you wrote __int__ instead of __init__


Grr,,, and I looked to make sure I did not post a misspelled code.

Thank you.


Hi there,

Why do I need this line Car.init(self, model, color, mpg) ?


To initialize the variables without reinputting

self.color = color
self.model = model
self.mpg = mpg