Help me please!


Hey guys - I've tried searching around the forum for answers to 20.2.8 that hold references that can help me alter my code - and I can't find anything... (modifying member variables)

The code outputs the first result - "new" but not the second one - why?
Please tell me what's going on and why the code isn't correcting itself....
I'm getting "Oops, try again. Make sure your Car class has a drive_car() method."

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 {color} {model} with {mpg} MPG.'.format(
        color = self.color,
        model = self.model,
        mpg = self.mpg))
    def drive_car(self):
        self.condition = "used"

print my_car.condition
print my_car.drive_car

Traceback (most recent call last):
  File "python", line 18, in <module>
AttributeError: 'Car' object has no attribute 'drive_car'


because drive_car is a method - you have to call it with parenthesis


just like calling a function, calling a method requires parentheses:



Thanks for your help - I figured it out! :blush:


thanks for your help - I really appreciated it!