Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Inheritance Super!

Ricardo Franco
seal-mask
.a{fill-rule:evenodd;}techdegree
Ricardo Franco
Data Analysis Techdegree Student 16,258 Points

Stuck on Super! coding challenge

Per instruction, I am trying to override the "add_item" method in the parent class by putting super() in the subclass. Any and all help is greatly appreciated. Thank you, in advance

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

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


class SortedInventory(Inventory):
    def __init__(self, item, **kwargs):
        super().__init__(item, **kwargs)
    pass

2 Answers

Steven Parker
Steven Parker
231,198 Points

The instructions ask you to "override the add_item method.", which still needs to be done. You won't need to override "__init__" in this challenge,

And you can remove "pass" once you add actual code.

Understand Steven has answered the question but I wanted to get used to using Community and see where I could help if i knew how to work it out!

Like Steven said, you're attempting to override the "init" method in this challenge. When it's asking for the "add_item" method to be. You're on the right tracks though!

I would simply change the super() to accept.add_item as opposed to init. Then for parameters, as we saw in the video you don't need to accept 'self'.

Carry on the append(item) like stated in the Parent Class underneath your new super() & you should be good!