Creating Class Methods Incorrect Output


#1

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 ,self.mpg)
       

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

I feel my code is correct and outputs the correct answer, but I get error message saying the output :Oops, try again. It looks like you didn't print "This is a silver DeLorean with 88 MPG.".


#3

Just give a full stop . in the display_car method's return just like this:

return "This is a %s %s with %s MPG." #<here

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.