-Could anyone please check over my code and see what's wrong?



Oops, try again.
my_car does not appear to be an instance of ElectricCar.

Code should store properties from ElectricCar class into my_car

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
    print my_car.condition

class ElectricCar(Car):
     def ___init__(self, model, color, mpg, battery_type):
         self.battery_type = battery_type
         my_car = ElectricCar("Red","Honda", 77, "molten salt")


Ask the question, "When is an instance declared in a class init definition?" Never, perhaps?

Remove all the indentation so this line is in not in local scope. Same applies to the four lines for my_car in the Car class.


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