7. Creating class methods


Oops, try again. It looks like you didn't print "This is a silver DeLorean with 88 MPG.".

hi mods... it looks like you arent supposed to print "new"?
but this gives error if i remove
condition = "new"

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 %s with %s MPG." % (self.condition,self.color, self.model, str(self.mpg)) 

my_car = Car("DeLorean", "silver", 88)
print my_car.display_car()


This line should be

return "This is a %s %s with %s MPG." % (self.color, self.model, str(self.mpg))

Everything else looks really good. It's hard to make sure the string prints exactly what the SCT looks for.


okay thx...
it worked :wink:


you are going to add a method to update the car condition in this next exercise, the condition shouldn't be added to the display_car method.


condition isn't needed