Creating Class Methods


Here is my work

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

Indentations are all there (i just didnt show them here). But the problem is that when submit the code I get an error message saying
Oops, try again. It looks like you didn't print "This is a silver DeLorean with 88 MPG.
even though it printed. I erased all of my codes and retyped it but i still get the same error message. Any ideas as to why this is happening? I appreciate the help. Thank you guys!


remove str() from your return and enter a new line between your return and def display_car: str(self.mpg)


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


Its still not working. I have no idea what is wrong.


Never mind! I figured it out and it was probably the stupidest mistake. I forgot to put a period after MPG. I appreciate the help though.


Had exactly the same issue, thanks for sharing ! :joy:


I am facing same problem. Thanks for sharing.


me too :smile: i forgot about how strict it is