Python Object-Oriented Python Inheritance Super!

Antonio Bello
Antonio Bello
12,215 Points

not working error keys getting thrown when i enter self.slots.sort()

Not sure what is wrong here

inventory.py
class Inventory:
    def __init__(self):
        self.slots = []

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

class SortedInventory(Inventory):
    def __init__(self):
        super().__init__()

    def add_item(self,item):
        super(SortedInventory,self).add_item(item)
        self.slots.sort()
Nick B.
Nick B.
Front End Web Development Techdegree Student 11,602 Points

English is not my first language so please bare with me.

def __init__(self):
     super().__init__()

 def add_item(self,item):
     super(SortedInventory,self).add_item(item)
     self.slots.sort()

This is where things go wrong. You wanna don't need to use def init anymore here. Just go ahead and erase that. You wanna replace it with def add_item, call super after that then sort the list in the end

I'll give you a hint.

class SortedInventory(Inventory):
    def add_item(self,item):
    ...
    ...

1 Answer

Steven Parker
Steven Parker
171,226 Points

The arguments to "super" are unnecessary (and apparently ignored), as is the override of "__init__". But I tried pasting this code directly into the challenge with no changes and it passed.

Try restarting your browser, I've heard that can help in cases of "false failure".