9.Inheritance can't figure out what is wrong

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/python-intermediate-en-egNXj/1/3?curriculum_id=4f89dab3d788890003000096

<In what way does your code behave incorrectly? Include ALL error messages.>
Getting following error:
Oops, try again. my_car does not appear to be an instance of ElectricCar.

and

Traceback (most recent call last):
File “python”, line 26, in
TypeError: init() takes exactly 4 arguments (5 given)
<What do you expect to happen instead?>

```python

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,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 int(self, model, color, mpg, battery_type):
Car.init(self, model, color, mpg)
self.battery_type = battery_type

my_car = ElectricCar(“Honda”, “Blue”, 32, “molten salt”)

<do not remove the three backticks above>
2 Likes

Hi that line

def __int__(self, model, color, mpg, battery_type):

you wrote __int__ instead of __init__

1 Like

Grr, and I looked to make sure I did not post a misspelled code.

Thank you.

Hi there,

Why do I need this line Car.init(self, model, color, mpg) ?

To initialize the variables without reinputting

self.color = color self.model = model self.mpg = mpg

1 Like