My code fails to update the condition of my_car after I drive it. It prints ‘new’ twice.
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, self.mpg) def drive_car(self): self.condition = "used" class ElectricCar(Car): def __init__(self, model, color, mpg, battery_type): self.model = model self.color = color self.mpg = mpg self.battery_type = battery_type def drive_car(self): self.conditon = "like new" my_car = ElectricCar("VW", "Blue", 100, "molten salt") print my_car.condition my_car.drive_car() print my_car.condition
I can’t see the difference between this and the solution code. I’m sure it’s something stupid. Can anyone tell me what’s happening?