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

Keifer Joedicker
Keifer Joedicker
5,869 Points

Why isn't this passing through?

I'm not sure if its asking me to randomly have it add or subtract 3. I'm not sure why this isn't passing

frustration.py
Class Liar(list):
    def __len__(self):
        return super().__len__(self) - 3

2 Answers

Steven Parker
Steven Parker
231,275 Points

You're close, but you have a few issues:

  • you wrote "Class", but the class keyword is spelled with all lower case
  • you don't need to pass self to the parent __len__ function
  • you should be sure your function never returns a negative value
Keifer Joedicker
Keifer Joedicker
5,869 Points

Aside from the directions of this code challenge, is there any other reasons why I should make sure my function doesn't return a negative?

Steven Parker
Steven Parker
231,275 Points

You specifically asked for reasons why it would not pass the challenge.

But other than that...
It wouldn't cause any kind of syntax error, but it wouldn't be an effective "lie" to say a length was negative.

Keifer Joedicker
Keifer Joedicker
5,869 Points

@Steven Parker okay just making sure.

Thank you for your help.