Modifying number variable--- please help


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 %s MPG." %(self.color, self.model, str(self.mpg))
    def drive_car(self):
        self.condition = "used"
my_car = Car("DeLorean", "silver", 88)
print my_car.condition()
print my_car.drive_car()

error- Traceback (most recent call last):
  File "python", line 14, in <module>
TypeError: 'str' object is not callable



print my_car.condition()

you try to access a member variable, this should be done without parentheses, the parentheses are for calling methods, condition is not a method


why is it not printing my_car.drive_car() value


because you made a syntax problem in the line above? like i explained


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