Python Object-Oriented Python Advanced Objects Frustration

What is wrong with my code please?

Now I want you to make a subclass of list. Name it Liar.

Override the len method so that it always returns the wrong number of items in the list. For example, if a list has 5 members, the Liar class might say it has 8 or 2.

You'll probably need super() for this.

frustration.py
class Liar(list):
    def __len__(self, list1):
        super().__len__()
        return (len(list1) - 2)

1 Answer

Alex Koumparos
MOD
Alex Koumparos
Python Web Development Treehouse Moderator 33,371 Points

Hi Ammar,

You've got the right general idea but the initialiser for len() doesn't take a value (it's operating on self, which is the list instance). This means you need to get rid of the list1 parameter.

Instead of working with list1, you will be working with the value that super's initialiser returns.

Hope that makes sense

Cheers

Alex

Thank you so much Alex! Changed my code based on your comments and now passes the check!