__init__() takes 4 positional arguments but 5 were given

  python, python-3.x, super
class Car():    
    def __init__(self, modelname, price, yearm):
        self.modelname=modelname
        self.price = price
        self.yearm = yearm

class supercar(Car):    
    def __init__(self, modelname, price, yearm, cc):
        super().__init__(self, modelname, price, yearm)
        self.cc = cc
    
honda=supercar('city', 100000, 2017, 1500)

print(honda.price)

Source: Python Questions

LEAVE A COMMENT