Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Why isn't this working
Please help with this code challenge
class Liar(list): def len(self): return super().len + 7
The purpose of super is to call a method from the parent class. So in your code, you called
super().len(), so the
len() is suppose to be a method? Why did you call the
Here do this, since you called a method from the parent call
list, Check if there is a method called
len() in there, type this in your console.
Scroll through it until you find something similar to your version of
len() and see that the
super() you called, Is it calling the right method? or is something wrong with your version of
SPOILER DON'T SEE SOLUTION UNTIL NECESSARY READ ABOVE
class Liar(list): def __len__(self): return super().__len__() + 4
I would recommend that you get a proper understanding of the
super()and magic methods before continuing further in the course.
len is supposed to be a magic method, try using it as a magic method, your code is properly structured you are just missing a magic method. Give it a little try, If you still have problems that's okay just comment for help.
class Liar(list): def __len__(self): return self.super().len() + 7 ``` what's wrong here
As boi already mentioned
len is a magic method in this challenge task and you are missing something here:
return self.super().len() + 7
Also, you do not need to use
self at all.
Am I missing list? Also here is my updated code
class Liar(list): def __len__(self): return super().len() + 4
Can someone link the super and magic methods video