Python Object-Oriented Python Inheritance Super!

Unable to pass the Assignment.

class Inventory: def init(self): self.slots = []

def add_item(self, item):
    self.slots.append(item)

class SortedInventory(Inventory):

not sure how to override add_item in this class.

I did try to override the Init of the superclass and call the add_item method there.

def __init__(self,item,**kwargs):
    super(SortedInventory,self).add_item(item)
inventory.py
class Inventory:
    def __init__(self):
        self.slots = []


    def add_item(self, item):
        self.slots.append(item)

class SortedInventory(Inventory):
    super().add_item(item)

1 Answer

Your missing

    def add_item(self, item)

just below your

class SortedInventory(Inventory):

Happy coding, Shivam