Refferring to membre varables


#1



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


I can pass to the next exercise but there is a msg of error :
Oops, try again. my_car does not appear to be an instance of Car.

can someone give a simle explanation plz

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


#2

i think you should revisit this exercise to see how to create class instance or this one


#3

class Car(object):
pass
my_car = Car()
that is the right answer but when I wrote that is still wrong


#4

i linked to these exercises to remind you how to create class instances because this:

class my_car(Car):
#my_car = car(object):
    model = "DeLorean"
    color = "silver"
    mpg = 88

is not how you create a class instance.


#5

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