Welcome to the Treehouse Community
Looking to learn something new?
Iain Watson3,031 Points
Override add_item in Super! Task 2 of 3 (and cf override init in characters.py)
I'm not sure what this is asking. In characters.py there were 2 inits in Thief(Character) the 1st of which was used to add the attribute sneaky. I'm not sure how to override a method in the superclass and then have it still run in the subclass. And why would you want to do that?
class Inventory: def __init__(self): self.slots =  def add_item(self, item): self.slots.append(item) class SortedInventory(Inventory): def __init__(self): super().__init(item)
Oszkár FehérTreehouse Project Reviewer
Hello Watson, The Task asking to override the add_item() function, when you call super(), it is not necessary to override the init() funtion, with super you can override any function from the parent class
Of course for this you need to create an add_item() function in the child class to in order to be able to override the parent method
def add_item(item): super().add_item(item)
What you tried it's the init() method but the quiz doesn't ask that. Another thing in the future when you overide a buildin function or magic method, you should use "_" in both sides
otherwise if you let just the first 2 "__" that will create a protected method or variable if you use for variables
__name of the function or variable
I hope it was for your help. Happy coding.