8. Modifying Member Variables


#1


I keep getting this error message:
"Oops, try again. You should set the new condition in drive_car() by updating the value of self.condition."

I don't understand why the condition is not being updated.


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

print my_car.condition
my_car.drive_car()
print my_car.condition


#2

Don't hate me... misspell.


#3

Oh my god, thank you, this was driving me nuts. Can't believe I didn't see this. Thank you very much.


#4

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