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


#1



https://www.codecademy.com/courses/python-intermediate-en-egNXj/0/5?curriculum_id=4f89dab3d788890003000096#


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

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


#2

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.


#3

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