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

Patrick Perkins
Patrick Perkins
14,619 Points

Object-Oriented Python Frustration Challenge

I am having a bit of trouble getting this bit of code to work. The objective is to override the len() method to work on a list subclass, Liar, Any tips are appreciated

frustration.py
class Liar(list):
    def __len__(self):
        return super().__len__(self) + 3

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,861 Points

Hi Patrick,

So close! You have one small error in this line:

return super().__len__(self) + 3

When you call the __len__ method on the superclass you don't pass self: self is the argument that you define on all regular methods in a class but Python supplies self automatically when you call it.

Hope that helps,

Cheers

Alex