7. Criando métodos de classe - Impossible to advance with non-sense message


#1

In lesson 7 I can't advance even with a correct message being displayed.

My code:
`class Car(object):
condition = "novo"
def init(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
def display_car(self):
return "Este e um %s cor %s com consumo de %d MPG." %(self.model, self.color, self.mpg)

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

The displayed message:
Este e um DeLorean cor prata com consumo de 88 MPG.

The error message:
Oops, tente outra vez. Parece que voce nao exibiu "Este e um DeLorean cor prata com consumo de 88 MPG.".

What is exactly wrong here? I've tried %d and %s to display mpg value, but no success.


#2

Try
return "Este e um %s cor %s com consumo de %s MPG." % (self.model, self.color, str(self.mpg))

sometimes codeacademy doesnt accept your answer when you dont do exactly as you are told to


#3

It didn't work. :disappointed:


#4

this worked for me:
`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"+" "+self.color+" "+self.model+" "+"with"+" "+str(self.mpg)+" MPG."

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