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 Advanced Objects Frustration

Can you please help with that task, cannot understand fully how to do it

df

frustration.py
class Liar(list):
    def __len__(self,list):
        super()>

1 Answer

Josh Keenan
Josh Keenan
19,652 Points

I'll walk you through my solution:

class Liar(list):
    def __len__(self):
        return super().__len__() + 1 

So the challenge says that we don't need to pass it any extra parameters at all, so that means we just need to pass it self and nothing more.

So the return is calling the len from the parent class, List, and it will be called on itself, so essentially you could see it working something like len(self), and then since the return is an integer we can just add 1 to it at the end.

If you have any questions feel free to ask, and check out this thread for more info about super() if you want.