Initializing a class


Traceback (most recent call last):
File "python", line 8, in
File "python", line 4, in init
NameError: global name 'condition' is not defined

I dont understand the error, in codeacedemy it has been accepted.

Replace this line with your code. 
class Car(object):
    def __init__(self,model,color,mpg):

print my_car.condition


MY doubt is that do we need the dot notation to access our member variables which are created in the class itself also? since in
"Referring to member variables"
it has been written that ;-
" Calling class member variables works the same whether those values are created within the class (like our car's condition) or values are passed into the new object at initialization. We use dot notation to access the member variables of classes since those variables belong to the object "


since there is no condition parameter, the error is being raised. You have three parameters and three corresponding member variables, Should you not be assigning the parameters accordingly?


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