Calling class member variables


my console is displaying this error
Traceback (most recent call last):
File "python", line 5, in
NameError: name 'my_car' is not defined

i expect a print 'my car is new'

class Car(object):
    condition = 'new'
    def __init__(self):
        my_car = Car()
print my_car.condition

"""My codes permits me to the next lesson, but it is not printing my car condition . proceeding might lead to a worse error i guess, sb help please"""


why does your Car class an init method, remove the init and create the my_car instance outside the class


thank you so much, i rectified my mistakes, i had to go back to the previous lesson to refresh everything ,,now working well.i figured it out.


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