8. Modifying Member Variables


#1

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

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()



#2

Hi @jeremie068,

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

        self.conditon = "used"

#3

Oh wow, silly mistake, thank you!


#4