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.

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,429 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.