Modifying Member Variables


#1



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


Oops, try again. You should set the new condition in drive_car() by updating the value of self.condition. The condition of my car isn't charging after I drive.


I expect it to go from "new" to "used"


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg
    
    def display_car(self):
        print "This is a %s %s with %i MPG." %(self.color, self.model, self.mpg)
    def drive_car(self):
        self.condtion = "used"

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


#2

You updated a different attribute, check your spelling


#3

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