5.Initializing a class. Error but still passes?



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)


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


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