need some help with this
driving the electric car.
in the following lines of code I get the following error:
File "python", line 28 def drive_car(self): ^ IndentationError: unexpected indent
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) print my_car.condition my_car.drive_car() print my_car.condition class ElectricCar(Car): def __init__(self, battery_type, model, color, mpg): self.battery_type = battery_type self.model = model self.color = color self.mpg = mpg my_car = ElectricCar("molten salt", "Coralla", "White", 35) def drive_car(self): self.condition = "like new" print my_car.condition my_car.drive_car() print my_car.condition
So I remove that indent and run the program. But when I drive the car, it is not printing "like new" but rather:
new used new used
so can some assist me in understanding why the Overriding methods is not working when I drive the electric car.