Nicolae Laurentiu1,538 Points
I don't understand why do I have to use super() function. It is so confusing. Could anyone explain me in a more basic ?
No idea how to resolve the exercise. Please, I need help with the super() class. I don't understand it at all .
class Inventory: def __init__(self): self.slots =  def add_item(self, item): self.slots.append(item) class SortedInventory(Inventory): def __init__(self, item): self.slots =  super().__init__() def add_item(item): super().add_item(item)
Steven Parker171,141 Points
You might think of "super()" as meaning "use the one in the base class instead of my own".
For example, both classes shown here have a method called "add_item", but if you are writing code inside the "SortedInventory" class you don't want to call it's own method. By putting "super()" in front of "add_item()" you are calling the one in the "Inventory" class instead (the base or "parent" class).
You have actually done that part correctly in your challenge code, but there are two other issues preventing it from passing:
- the instructions did not ask you to override the "
__init__" method (you can remove that code)
- the "add_item" method needs "self" as the first parameter