7. Creating class methods



Receiving File "python", line 10
my_car = Car("DeLorean", "silver", 88)
SyntaxError: invalid syntax


Oops, try again. Make sure your Car class has a display_car() method.

expected it to print This is a silver DeLorean with 88 MPG.

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.model, self.color, str(self.mpg)

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


The print format in the return statement is missing a ) at the very end.


wow.. lol thank you ))))))


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