5.Initializing a class. Error but still passes?


#1



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


My Code passes, even though there is an error message. The error is:

Traceback (most recent call last):
File "python", line 7, in
File "python", line 3, in init
AttributeError: 'Car' object has no attribute 'model'


class Car(object):
    def __init__(self, model, color, mpg):
        model = self.model
        color = self.color
        mpg = self.mpg

my_car = Car("DeLorean", "silver", 88)


#2

It should not have, but that is a possibility given that the SCT is usually not very exhaustive.

The member variables go on the left side, and the parameter arguments on the right.

self.model = model

#3

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