What is wrong with the inherinted class?


#1


error message " Traceback (most recent call last):
  File "python", line 26, in <module>
TypeError: 'str' object is not callable "
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, str(self.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

class ElectricCar(Car):
    def __init__(self,model, color, mpg, battery_type):
        self.battery_type = battery_type
        self.model = model
        self.color = color
        self.mpg = mpg
    def drive_car(self):
        self.condition = "like new"
my_car = ElectricCar("Camery", "Black", 220, "molten salt")
print my_car.condition()
my_car.drive_car()
print my_car.condition()


#2

Hello @bytemaster34725,

the "O" in object should be capital, and try removing the parentheses of my_car.condition. That should fix your problem...


#3

@bytemaster34725
Read this article
https://discuss.codecademy.com/t/this-looks-like-a-job-for/44602/3?u=leonhard.wettengmx.n


#4

@bytemaster34725,

and read this, so you know what you are doing....
http://stackoverflow.com/questions/68645/static-class-variables-in-python


#5

thanks alot. but i have been using small "o" ever since. let me try your solution


#6

removing the parenthesis in the print statement worked. but i did maintain the small "o" i the object. my code finally worked. thanks leonhard.wettengmx.n