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 trialFrances Angulo
5,311 Pointsoverride and super()
I thought I was already overriding the add_item method, now I'm completely lost as to what to do next.
class Inventory:
def __init__(self):
self.slots = []
def add_item(self, item):
self.slots.append(item)
class SortedInventory(Inventory):
def __init__(self, add_item):
super().__init__(add_item)
3 Answers
Steven Parker
231,236 PointsThere's no override for "add_item" here, but instead there is an override for "__init__
" (which is not needed).
I see "add_item" being passed as an argument but that also isn't needed for this challenge.
Frances Angulo
5,311 PointsI had to start the entire OO section over to get this right and I am still not sure how I got to the right answer. Woof.
Frances Angulo
5,311 PointsYeah I got there I just had to go back and re-watch from the beginning of the OO course and then give a few swings at the answer... still only 60-70% there in terms of understanding.
Any plans for a TechDegree that covers this content?
Steven Parker
231,236 PointsIsn't this course already part of the Techdegree program?
Anyway, glad I could help. Happy coding!
Steven Parker
231,236 PointsSteven Parker
231,236 PointsYou're kind of close, just change "init" to "add_item" and leave off the extra argument.
Sean Coutinho
7,788 PointsSean Coutinho
7,788 PointsWhy is this not working for me? Lol. I used the same code and changed "init" to "add_item" but I still get a Try Again.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsDid you change it in both places?