Inheritance


#1



Inheritance

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

why its saying it takes only 4 argument when i defined 5 arguments


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"
    
    

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, model, color, mpg):
        self.battery_type = battery_type
        self.model = model
        self.color = color
        self.mpg   = mpg
my_car = ElectricCar("molten salt","model","color","mpg")


#2

sorry i found mistake


#3