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!

Ryan McGuire
Ryan McGuire
3,758 Points

Stuck again, sorry, I don't understand why questions show up below the lectures but not below the quizzes.

If anyone can offer feedback on where I went wrong. I am unfortunately guessing a little because the previous video didn't provide many examples or exercises before getting to this one.

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

    def add_item(self, item):
        self.slots.append(item)
        super()
class SortedInventory(Inventory):
        def __init__(self,*args, **kwargs):
            super().__init__(*args, **kwargs)

1 Answer

Steven Parker
Steven Parker
231,275 Points

It looks like you've passed task 1 already. Good so far.

The instructions for task 2 say "Now override the add_item method.", but the code shown here is overriding "__init__" instead.

Ryan McGuire
Ryan McGuire
3,758 Points

Thanks, still not there. I did not really understand what they meant by override.

Steven Parker
Steven Parker
231,275 Points

An "override" is a method that has the same name as a method of the super class. But the issue here is that the method implemented has the wrong name.