Why, doesn't, this, work!


#1

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, model, color, mpg, battery_type):
        self.battery_type = battery_type
        return super(ElectricCar, self).__init__(model, color, mpg)
    def drive_car(self):
        self.condition = "like new"
        
my_car = ElectricCar("Prada", "Blue", 90, "molten salt")
print my_car.condition
my_car.drive_car()

PLEASE HELP ME, I'VE BEEN AT THIS FOR 3 DAYS AND I STILL CAN'T GET IT TO WORK


#2

Hey there! I think you've forgotten to print the condition of the car after driving in it.

And also, are you sure .__init__ takes parameters in this line? return super(ElectricCar, self).__init__(model, color, mpg)

I tried it in a different editor than CodeCademy and it gave me an error when there were parameters.


#3

What error did it give you?


#4

File "python", line 25
self.condition = "like new"
^
IndentationError: expected an indented block

Oops, try again. Make sure you've defined a new ElectricCar class after defining Car.


#5

The only thing I can see here is an unnecessary return. Just write,

    super(ElectricCar,self).__init__(model, color, mpg)