Python Object-Oriented Python Inheritance Super!

Travis John Villanueva
Travis John Villanueva
5,052 Points

Super! 3/3 - Im lost

Hi Team

I think im lost regarding this problem. The problem require a sorted list after adding an item using a super class method inheriting to its child class. I have applied the inheritance properly and my Sortedinventory inherits that method properly but i dont know how to proceed further as i have this query on my head

My list of problem:

  1. Once items are added, i should call the slots list to perform slots = slots.sort() however, i dont know where would i call it.
  2. I have the thought that once i perform the class SortedInventory(Inventory) - did i also call automatically the self.slots
  3. So, my understanding is this should be easy, call the list that contains the added items can you provide me with a step by step logic?
inventory.py
class Inventory:
    def __init__(self):
        self.slots = []

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

class SortedInventory(Inventory):

    def add_item(self, item):
        super().add_item(item)

1 Answer

Jordan Hoover
Jordan Hoover
Python Web Development Techdegree Graduate 59,011 Points

I'm not totally clear on your question, but I think you're overthinking it. Just sort the property after the super method has been called. Make sense?