9/11 Inheritance


#1

Hello!

During exercise 9 of classesm, I think i miss understood inheritance. What is the point of inheritance if the following code does not work? I read that it has something to do with overwriting init(). In my view, you do that to only add the extra member this specific class within the parent class has...

> class ElectricCar(Car):
>     def __init__(self, battery_type):
>         self.battery_type=battery_type

and this one does work?

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

thanks for your help, really appreciate it!

Edit: I don't know how to do the indents in the quoted code. Just believe I did the indents correct :slightly_smiling:
Edit2: I figured it out :slightly_smiling:


#2

Sorry, i looked over this topic, here it is well explained.