Overriding Methods


#1



https://www.codecademy.com/courses/python-intermediate-en-egNXj/1/4?curriculum_id=4f89dab3d788890003000096


My override for "used" works, but I've done something incorrectly and my override for "like new" is not executing. I''ve been tinkering but haven't been able to resolve. Here's the error message:

Oops, try again. It looks like you didn't update the condition of my_car to 'like new'.


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

def drive_car(self):
    self.condition = "like new" 

my_car.drive_car()
print my_car.condition


#2

I figured it out. Had to move the override above the instance of ElectricCar that I had created.


#3