Overriding methods, prints mixed_up gibberish


Exercise link:

This is what it prints, misplacing "Delahaye" instead of "100":
PS: I did "talk to the duck" prior posting... :slight_smile:

This is a 100 red molten battery with Delahaye MPG.
like new


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg = 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
    def drive_car(self):
        self.condition = "like new"
    def display_car(self):
        print  "This is a %s %s %s with %s MPG." % (self.battery_type,self.color, self.model, str(self.mpg))
my_car = ElectricCar( "molten salt","Delahaye", "red", 100)

print my_car.display_car()
print my_car.condition
print my_car.condition


Hi, @anaestereo,

The duck has advised me to have you to compare the order of the parameters in this method header ...

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

... to the order of the arguments in this instantiation statement ...

my_car = ElectricCar( "molten salt","Delahaye", "red", 100)

The order of the arguments in your instantiation statement should correspond to the order of the parameters in the __init__ method header. For example, the model should be the first argument, and color second.


I knew that duck was nothing but trouble!!!! :slight_smile:

thanks a ton, appylpye.....I got my eyes set on the top method header for the Car class rather than the ElectricCar from which inherits....I really appreciate your time!!!