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 " + my_car.color + " " + my_car.model + " with " + str(my_car.mpg) + " 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): my_car.model = model my_car.color = color my_car.mpg = mpg my_car.battery_type = battery my_car.battery_type("molten salt") my_car.model("DeLorean") my_car.color("Red") my_car.mpg = 88
We've already answered this question in your previous topic. Go back and read it carefully.
Also, please visit the topic on Formatting Code Samples in posts that is pinned at the top of the General Index.
I don't get it. Can't you help me on here?
Which thread do you wish to keep? Is this a new question? If so then the problem is that the earlier issue is still not resolved in the above code. It's confusing me.
We need to create an instance and pass the properties in the argument.
my_car = ElectricCar("DeLorean", "Red", 88, "molten salt")
The lines above (in the quote) should be removed from the code.
This needs to be fixed...
and same with the other two.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.