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

How do i call the list methods on Liar

How do i get the code to call the list methods on Liar and also how do I return the wrong Len

frustration.py
class Liar(list):
    def __init__(self, *args,**kwargs):
        super().__init__()
        alist = []

    def __len__(self):
        return self.alist

2 Answers

Steven Parker
Steven Parker
229,732 Points

Since you're inheriting from "list", you can call list methods by adding a "self." prefix for any you have not overridden, or a "super()." prefix for those you have.

And perhaps the easiest way to always return a wrong length is to get the correct length from the list, and then add some small fixed quantity to it.

Carlos Marin
Carlos Marin
8,009 Points

you only need to change the length of the object. remember: you are inheriting all the properties from the parent class: (list). you just need to override the way the len of the object is determined, by defining len.