7. Creating Class Methods - Getting confused


#1

Can anyone please help me? I'm printing what they're asking for but it says that I'm not


My code for anyone who wants to try it is:

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" \
        % (my_car.color , my_car.model, str(my_car.mpg))
        
my_car = Car("DeLorean", "silver", 88)
print my_car.display_car()

#2

Your string is slightly different


#3

Try this one:
You missed the dot and it should be in its general form self.color...etc.

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.display_car()


#4

Thank you it worked :slightly_smiling:


#5

Because you missed the period "." at the end of your sentence.