Calling drive_car does not work, removing it does? Bad directions?


The directions instruct us to call the drive_car() function/method. However, the code only works once 'drive_car(my_car)' or 'drive_car()' is deleted (I've tried both). I get the following error message:

Traceback (most recent call last):
File "python", line 15, in
NameError: name 'drive_car' is not defined

Clearly drive_car is defined on line 9.... But I am obviously missing something. Can you help?

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))
    def drive_car(self):
        self.condition = "used"
        return self.condition

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


@ingame4th ,

You have this line ...


Which Car do you want to drive, and how do you indicate that?


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