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.

Aizah Sadiq
2,434 PointsWhy isn't this working
Please help with this code challenge
class Liar(list):
def len(self):
return super().len + 7
6 Answers

boi
9,396 PointsThe 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 len()
method?
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.
help(list)
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 len()
.
SPOILER DON'T SEE SOLUTION UNTIL NECESSARY READ ABOVE
SOLUTION:
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.

boi
9,396 PointsSince 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.

Aizah Sadiq
2,434 Pointsclass Liar(list):
def __len__(self):
return self.super().len() + 7
```
what's wrong here

Ave Nurme
20,907 PointsAs 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.

Aizah Sadiq
2,434 PointsAm I missing list? Also here is my updated code
class Liar(list):
def __len__(self):
return super().len() + 4

boi
9,396 PointsYour code is correct, all you have missing are 4 underscores. let me give you a hint (len
).

Aizah Sadiq
2,434 PointsCan someone link the super and magic methods video