0

I have the class Dove that inherits from Animal and Bird. The parameters from Animal are passed by super(). How I can pass the parameters from Bird to Dove? I got this error: AttributeError: 'Dove' object has no attribute 'wings'

class Animal():
    def __init__(self, name):
        self.name = name

    def eat(self):
        print('{} is eating'.format(self.name))

class Bird():
    def __init__(self, wings):
        self.wings = wings

    def fly(self):
        print('Is time to fly with {} wings'.format(self.wings))

class Dove(Animal, Bird):
    def __init__(self, name, wings):
       super().__init__(name)
       Bird(self).__init__(wings)
       
    def action_fly(self):
        Bird.fly(self)
        
dove1=Dove('dove', 4)
dove1.action_fly()
  • Take a look at this: https://stackoverflow.com/questions/9575409/calling-parent-class-init-with-multiple-inheritance-whats-the-right-way it might help you. Also, swapping `Animal, Bird` to `Bird, Animal` and calling `super().__init__(wings)` will fix it, however you won't be able to initialize the `Animal`'s `name` automatically in the inheritance – nir shahar Jun 11 '21 at 22:58

0 Answers0