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 trialNoah Fields
13,985 PointsObject-Oriented Python, Code Challenge: Frustration, help
I am attempting the code challenge in Object-Oriented Python known as "frustration". True to its name, this is quite a tough challenge, and it involves creating a subclass of list called "Liar" with a redefined len() command which gives the incorrect value. What I find to be problematic here is that I somehow need to get the actual len() value at some point during this program, so that I can change the number to something which I can know with certainty is not accurate. I attempted to briefly use super().len() but to no avail, perhaps due to incorrect syntax. Are there any suggestions on the proper way to get the true len() value of a given variable in such a situation?
class Liar(list):
def __init__(self, *args, **kwargs):
for x in self:
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThere are parts to this challenge:
- create a
class Liar
that is a subclass oflist
- create a
__len__
method (which will override the inherited version). Onlyself
parameter needed. - call the parent
__len__
method use:super().__len__(self)
Post back if you need more help. Good Luck!!