Inheritance - (11 Introduction to Classes - Classes)


Guys, please help me! My code is work well, but always return the message " Make sure you’ve defined a new ElectricCar class after defining 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 %d MPG." % (self.color, self.model, self.mpg)

def drive_car(self):
    self.condition = "used"

my_car = Car(“DeLorean”, “silver”, 88)

print my_car.model
print my_car.color
print my_car.mpg
print my_car.condition
print my_car.condition

class EletricCar(Car):

def __init__(self, model, color, mpg, battery_type):
    self.battery_type = battery_type
    super(EletricCar, self).__init__(model, color, mpg)

my_car = EletricCar(“Sedan”, “blue”, 2017, “molten salt”)

print my_car.model
print my_car.color
print my_car.mpg
print my_car.battery_type


It’s the code on lines 16-21. The editor wants to see the output of ElectricCar and not Car. Comment those lines of code out or remove them. See if that lets you move forward, as your code looks good.


Thank you, but the problem wasn’t it. I defined “EletricCar” instead “ElectricCar”, when a put the “c” the problem was solved.


Perfect. My eyes skipped right over the typo. Great job finding it yourself.


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