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 trialKeifer Joedicker
5,869 PointsWhy 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
Class Liar(list):
def __len__(self):
return super().__len__(self) - 3
2 Answers
Steven Parker
231,269 PointsYou'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
5,869 Points@Steven Parker okay just making sure.
Thank you for your help.
Keifer Joedicker
5,869 PointsKeifer Joedicker
5,869 PointsAside 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
231,269 PointsSteven Parker
231,269 PointsYou 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.