8. Modifying Member Variables



Error message:
Oops, try again. You didn’t display the ‘used’ condition of the car after drive_car().

The code prints “new” twice when it should be printing “used” when I call my_car.drive_car()
What am I doing wrong?

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, self.mpg)
    def drive_car(self):
        self.conditon = "used"
        return self.condition
my_car = Car("DeLorean", "silver", 88)
print my_car.condition
print my_car.drive_car()


Hi @jeremie068,

Check the spelling of the variable name in the drive_car method, here …

        self.conditon = "used"


Oh wow, silly mistake, thank you!