What do I miss?


9 - 20 : Inheritance???

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

Shouldn't the init method be re-written to take 5 args instead of 4??

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, str(self.mpg))
    def drive_car(self):
        self.condition = "used"

class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        super(ElectricCar, self).__init__(model, color, mpg)
        self.battery_type = battery_type
my_car = Car("Ferrari", "Blue", 5, "molten salt")


Hi @amangara,

Here you need to create an ElectricCar ...

my_car = Car("Ferrari", "Blue", 5, "molten salt")

You created a Car, instead, which would require one less argument than you have, and that raised the TypeError.

Try using the same arguments that you did, but instantiate an ElectricCar.