Calling class member variables


#1



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

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"""


#2

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


#3

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.


#4

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