Help me please!


#1



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)

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

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


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


#2

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


#3

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

classInstance.methodName()

#4

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


#5

thanks for your help - I really appreciated it!


#6