Creating Class Methods


#1



https://www.codecademy.com/courses/python-intermediate-en-egNXj/1/1?curriculum_id=4f89dab3d788890003000096#


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


Could you please help me with this? I'm trying to figure it out, but I just don't get it


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 str("This is a %s %s with %s MPG." %(self.color, self.model, self.mpg)

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


#2

The pointer indicates where parsing stopped due to some unexpected character or object. The actual error is in the previous line... A missing closing parens, ).


#3

Thank you!! :grin:


#4

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