8 - Modifying meber variables


#1


8 - 20: Modifying member variables

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

How can my third method not be defined as I actually did it inside of the class 'Car' ?


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"
my_car = Car("DeLorean", "silver", 88)
print my_car.condition
drive_car(my_car)
print my_car.condition


#2

You're looking for drive_car among global variables, perhaps you created a drive_car somewhere else


#3

i sorted it out, great!


#4