7. Creating class methods


#1

Hi please I need help with my code, i don't know the problem

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

I actually got this error Oops, try again. You should get a description of my_car by calling my_car.display_car().


#2

Check that line, there is something missing in your function.


#3

Got it thanks

The parenthesis is very important


#4

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