Modifying member variables


TypeError: 'str' object is not callable

Hi, I am not sure what I missed there...

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.condition = "used"

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


Hi, @aviss

Check this statement ...

print my_car.condition()

Is that the correct syntax for accessing the condition variable?

Also reconsider this statement ...


Something is missing there. Which car do you want to drive?


Thanks! And spotted another typo. Works now!


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