Modifying member variables: ERROR


#1



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 "+ self.color +" "+ self.model+" with "+ str(self.mpg) +" MPG"
        
    def drive_car(self):
        self.condition = "Used"

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

I cant understand my error. It says : "You didn't display the 'used' condition of the car after drive_car()."


#2

Hi @heeeraa,

The instructions state ...

Inside the Car class, add a method drive_car() that sets self.condition to the string "used".

You set it to "Used" instead of "used".


#3

To expand on what @appylpye said, CodeAcademy is case sensitive in its courses. If your text doesn't EXACTLY match (meaning lower case and upper case too) what the instructions state, then it will reject your solution as wrong. Just something to watch out for in the future! :slight_smile:


#4

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