10. Overriding methods


Hi Guys,
Need your help
Check my code many times. Tried to find the answer, many people faced with the same problem. I get "Oops, try again. It looks like you didn't update the condition of my_car to 'like new'."

I console output I got
"like new" but the program send me error message


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg
    def display_car(self): 
        print "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)

class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        self.battery_type = battery_type
        self.model = model
        self.color = color
        self.mpg   = mpg
    def drive_car(self):
        self.condition = "like_new"

my_car = ElectricCar("Tesla", "White", 33, "molten salt")

print my_car.condition
print my_car.condition.>


like new should have a space between the words, not a underscore?


Oooo stetim94 thank you very much! It was just spelling not coding error. I spend more than 1 hour in debugging before decided to write here =)))


Issue resolved? Yep, it was just a spelling error, codecademy is sometimes strict in spelling


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.