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!

devante wallace
devante wallace
5,151 Points

Can someone please help me with my code?

I have no clue what to do with this question. I dont really understand how what it means by override?

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

    def add_item(self, item):
        self.slots.append(item)
class SortedInventory(Inventory):
    super().init(self):
        def init.(self, item):
        self.slots.append(item)

1 Answer

Steven Parker
Steven Parker
231,271 Points

An "override" is when you create a method that has the same name as method in the parent ("super") class.

Here's a few hints on the code:

  • be sure your method has the correct name (including underscores)
  • be sure to use the correct name when calling the "super" version
  • make sure the call to the "super" is within the new method
  • a method call should not be followed by a colon
  • check the indentation