6/10 Help pls


#1

The error message is that "my_car does not appear to be an instance of Car". Why? I see no indication that that's true. Please help me.

class Car(object):

condition = "new"

def __init__(self, model, color, mpg):
    self.model = model
    self.color = color
    self.mpg = mpg

my_car.model = "DeLorean"
my_car.color = "silver"
my_car.mpg = 88

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

#2

In fact you didn't create instance of class Car. To create object (instance of class) you must use following syntax: my_car = Car("DeLorean", "silver", 88) Then you can reach your variables like model, color, mpg which will be assigned from class to my_car object.


#3

class Car(object):
condition = "new"
def init(self, model, color, mpg):
self.model=model
self.color=color
self.mpg=mpg
def display_car(self):
return 'This is a %s %s with %s MPG.' % (self.color, self.model, str(self.mpg))
my_car = Car("Delorean", "silver", 88)
print my_car.condition
print my_car.display_car()
This is my code and it isnt working. Ive been staring at it for like an hour and its starting to piss me off. any help would be great


#4

Correct code:

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


#5

That is for the wrong lesson. That's from lesson 7, not 6.