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.

Juneau Lim
13,362 PointsQuestion about my Liar
question about my Liar When I did below, it didn't work.
class Liar(list):
def __len__(self):
truth = super().__len__()
return truth * 2 # error
However, when I changed the last line to +, it was ok.
return truth + 2 # OK
What is the difference? I have no idea.
1 Answer

Steven Parker
221,902 PointsThe challenge wants your function to always return an incorrect value (a "lie").
The problem with "truth * 2
" is that when the actual value is 0, your function will return the true value.
Juneau Lim
13,362 PointsJuneau Lim
13,362 PointsWow, that's a gotcha. I haven't think about that case. Thanks for the answer!
Juneau Lim
13,362 PointsJuneau Lim
13,362 PointsSorry I thought I did it. :-(