Creating cl*** methods (SyntaxError)


Creating class methods:
Getting a syntax error for a part of code that is the same as in all previous exercises and was working fine.

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

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

Was expecting no syntax error

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


look at the parentheses on the line above your error message


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