6. Referring to member variables


When I paste the following code into my own IDE it prints out just what the question aks for. However, I couldn't pass the task because it raises an error message:

You need to pass three arguments when creating a Car().

Please can someone help xx

class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg = mpg
my_car = Car("DeLorean", "silver", 88) 

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


It does not throw any error! ( I just tested it)
Can you clarify more?

copy this same code of yours and try to run!


yh it works, thnx a lot! Not shown in this post, but I added some comments with # to help me remembering the task; now that i've deleted them, it works perfectly


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