Traceback (most recent call last):
File "python", line 25, in
TypeError: init() takes exactly 2 arguments (5 given)
I have three questions:
1.Should I declare model, color and MPG again in the inherited class too?
2.In the order of passing the arguments, is battery_type the last?
3.In another post, Codeacademy clarified to me that ,'super' is used in cases where one particular method has to be both overridden and retained as defined in the parent class.
Should I use the super function in this case? If so, I do not understand why?
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 my_car.drive_car() print my_car.condition class ElectricCar(Car): def __init__(self,battery_type): self.battery_type=battery_type my_Car =ElectricCar("Jaguar", "Black", 95, "molten salt")