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!
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
Noah Fields13,985 Points
Object-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:
Chris FreemanTreehouse Moderator 68,332 Points
There are parts to this challenge:
- create a
class Liarthat is a subclass of
- create a
__len__method (which will override the inherited version). Only
- call the parent
Post back if you need more help. Good Luck!!